CacheKit provides reusable caching utilities and integrations for NestJS services.
- β CSR Architecture - Controller-Service-Repository pattern
- β TypeScript - Strict mode with path aliases
- β Testing - Jest with 80% coverage threshold
- β Code Quality - ESLint + Prettier + Husky
- β Versioning - Changesets for semantic versioning
- β CI/CD - GitHub Actions workflows
- β Documentation - Complete Copilot instructions
- β Examples - Full working examples for all layers
# Clone CacheKit
git clone https://github.com/CISCODE-MA/CacheKit.git cachekit
cd cachekit
# Install dependencies
npm install
# Start developing
npm run build
npm testsrc/
βββ index.ts # PUBLIC API exports
βββ {module-name}.module.ts # NestJS module definition
β
βββ controllers/ # HTTP Layer
β βββ example.controller.ts
β
βββ services/ # Business Logic
β βββ example.service.ts
β
βββ entities/ # Domain Models
β βββ example.entity.ts
β
βββ repositories/ # Data Access
β βββ example.repository.ts
β
βββ guards/ # Auth Guards
β βββ example.guard.ts
β
βββ decorators/ # Custom Decorators
β βββ example.decorator.ts
β
βββ dto/ # Data Transfer Objects
β βββ create-example.dto.ts
β βββ update-example.dto.ts
β
βββ filters/ # Exception Filters
βββ middleware/ # Middleware
βββ config/ # Configuration
βββ utils/ # Utilities
// src/example-kit.module.ts
import { Module, DynamicModule } from "@nestjs/common";
import { ExampleService } from "@services/example.service";
@Module({})
export class ExampleKitModule {
static forRoot(options: ExampleKitOptions): DynamicModule {
return {
module: ExampleKitModule,
providers: [ExampleService],
exports: [ExampleService],
};
}
}// src/services/example.service.ts
import { Injectable } from "@nestjs/common";
@Injectable()
export class ExampleService {
async doSomething(data: string): Promise<string> {
return `Processed: ${data}`;
}
}// src/dto/create-example.dto.ts
import { IsString, IsNotEmpty } from "class-validator";
export class CreateExampleDto {
@IsString()
@IsNotEmpty()
name: string;
}// src/index.ts
export { ExampleKitModule } from "./example-kit.module";
export { ExampleService } from "./services/example.service";
export { CreateExampleDto } from "./dto/create-example.dto";# Development
npm run build # Build the package
npm run build:watch # Build in watch mode
npm run typecheck # TypeScript type checking
# Testing
npm test # Run tests
npm run test:watch # Run tests in watch mode
npm run test:cov # Run tests with coverage
# Code Quality
npm run lint # Run ESLint
npm run format # Check formatting
npm run format:write # Fix formatting
# Release
npx changeset # Create a changeset
npm run release # Publish to npm (CI does this)This template uses Changesets for version management.
git checkout develop
git checkout -b feature/my-feature
# Make your changesnpx changesetSelect the change type:
- patch - Bug fixes
- minor - New features (backwards compatible)
- major - Breaking changes
git add .
git commit -m "feat: add new feature"
git push origin feature/my-feature
# Create PR β develop- Automation opens "Version Packages" PR
- Merge to
masterto publish
Tests are MANDATORY for all public APIs.
// src/services/example.service.spec.ts
describe("ExampleService", () => {
let service: ExampleService;
beforeEach(async () => {
const module = await Test.createTestingModule({
providers: [ExampleService],
}).compile();
service = module.get(ExampleService);
});
it("should be defined", () => {
expect(service).toBeDefined();
});
it("should process data correctly", async () => {
const result = await service.doSomething("test");
expect(result).toBe("Processed: test");
});
});Coverage threshold: 80%
Configured in tsconfig.json:
import { ExampleService } from "@services/example.service";
import { CreateExampleDto } from "@dtos/create-example.dto";
import { Example } from "@entities/example.entity";
import { ExampleRepository } from "@repos/example.repository";Available aliases:
@/*βsrc/*@controllers/*βsrc/controllers/*@services/*βsrc/services/*@entities/*βsrc/entities/*@repos/*βsrc/repositories/*@dtos/*βsrc/dto/*@guards/*βsrc/guards/*@decorators/*βsrc/decorators/*@config/*βsrc/config/*@utils/*βsrc/utils/*
- β Input validation on all DTOs (class-validator)
- β Environment variables for secrets
- β No hardcoded credentials
- β Proper error handling
- β Rate limiting on public endpoints
This template includes comprehensive Copilot instructions in .github/copilot-instructions.md:
- Module architecture guidelines
- Naming conventions
- Testing requirements
- Documentation standards
- Export patterns
- Security best practices
- Architecture - Detailed architecture overview
- Release Process - How to release versions
- Copilot Instructions - AI development guidelines
- Rename the module: Update
package.jsonname - Update description: Modify
package.jsondescription - Configure exports: Edit
src/index.ts - Add dependencies: Update
peerDependenciesanddependencies - Customize structure: Add/remove directories as needed
β DO export:
- Module
- Services
- DTOs
- Guards
- Decorators
- Types/Interfaces
β DON'T export:
- Entities
- Repositories
Entities and repositories are internal implementation details.
- MAJOR (x.0.0) - Breaking changes
- MINOR (0.x.0) - New features (backwards compatible)
- PATCH (0.0.x) - Bug fixes
- All tests passing (80%+ coverage)
- No ESLint warnings
- TypeScript strict mode passing
- All public APIs documented (JSDoc)
- README updated
- Changeset created
- Breaking changes documented
-
.env.exampleupdated (if needed)
MIT
See CONTRIBUTING.md
Made with β€οΈ by CisCode