├── .prettierrc ├── tsconfig.build.json ├── src ├── users │ ├── entities │ │ └── user.entity.ts │ ├── dtos │ │ └── create-user.dto.ts │ ├── user.repository.ts │ ├── schemas │ │ └── user.schema.ts │ ├── users.service.spec.ts │ ├── users.controller.spec.ts │ ├── user.module.ts │ ├── user-mongo.repository.ts │ ├── users.service.ts │ └── users.controller.ts ├── config │ ├── config-options.ts │ ├── config-loader.ts │ └── env-schema.ts ├── auth │ ├── auth.middleware.spec.ts │ ├── auth.service.ts │ ├── auth.middleware.ts │ ├── auth.service.spec.ts │ ├── api-key.strategy.ts │ └── auth.module.ts ├── correlation-id.middleware.ts ├── main.ts ├── logger │ └── logger-options.ts └── app.module.ts ├── nest-cli.json ├── test ├── jest-e2e.json └── app.e2e-spec.ts ├── docker-compose.yml ├── .gitignore ├── tsconfig.json ├── .eslintrc.js ├── package.json └── README.md /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /src/users/entities/user.entity.ts: -------------------------------------------------------------------------------- 1 | export class User { 2 | id: string; 3 | email: string; 4 | age: number; 5 | createdAt: Date; 6 | updatedAt: Date; 7 | } 8 | -------------------------------------------------------------------------------- /nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src", 5 | "compilerOptions": { 6 | "deleteOutDir": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/config/config-options.ts: -------------------------------------------------------------------------------- 1 | import { configLoader } from './config-loader'; 2 | import { envSchema } from './env-schema'; 3 | 4 | export const configOptions = { 5 | load: [configLoader], 6 | validationSchema: envSchema, 7 | }; 8 | -------------------------------------------------------------------------------- /src/auth/auth.middleware.spec.ts: -------------------------------------------------------------------------------- 1 | import { AuthMiddleware } from './auth.middleware'; 2 | 3 | describe('AuthMiddleware', () => { 4 | it('should be defined', () => { 5 | expect(new AuthMiddleware()).toBeDefined(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /src/users/dtos/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsInt, IsString, Min } from 'class-validator'; 2 | 3 | export class CreateUserDto { 4 | @IsString() 5 | email: string; 6 | 7 | @IsInt() 8 | @Min(0) 9 | age: number; 10 | } 11 | -------------------------------------------------------------------------------- /test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | mongo: 5 | container_name: mongo 6 | image: 'mongo:4.4' 7 | environment: 8 | - MONGO_DATA_DIR=/data/db 9 | ports: 10 | - '27017:27017' 11 | volumes: 12 | - mongo:/data/db 13 | 14 | volumes: 15 | mongo: 16 | -------------------------------------------------------------------------------- /src/users/user.repository.ts: -------------------------------------------------------------------------------- 1 | import { User } from './entities/user.entity'; 2 | import { CreateUserDto } from './dtos/create-user.dto'; 3 | 4 | export const USER_REPOSITORY = 'UserRepository'; 5 | 6 | export interface UserRepository { 7 | findAll(): Promise; 8 | createUser(createUserDto: CreateUserDto): Promise; 9 | } 10 | -------------------------------------------------------------------------------- /src/config/config-loader.ts: -------------------------------------------------------------------------------- 1 | export const configLoader = () => { 2 | return { 3 | port: process.env.PORT, 4 | apiKey: process.env.API_KEY, 5 | environment: process.env.NODE_ENV, 6 | sentry: { 7 | dsn: process.env.SENTRY_DSN, 8 | enabled: process.env.SENTRY_ENABLED === 'true', 9 | }, 10 | mongo: { 11 | uri: process.env.MONGO_URI, 12 | }, 13 | }; 14 | }; 15 | -------------------------------------------------------------------------------- /src/config/env-schema.ts: -------------------------------------------------------------------------------- 1 | import * as Joi from 'joi'; 2 | 3 | export const envSchema = Joi.object({ 4 | PORT: Joi.string().default(3000), 5 | API_KEY: Joi.string().required(), 6 | NODE_ENV: Joi.string().default('development'), 7 | SENTRY_DSN: Joi.string().required(), 8 | SENTRY_ENABLED: Joi.string().default('false').allow('true', 'false'), 9 | MONGO_URI: Joi.string().required(), 10 | }); 11 | -------------------------------------------------------------------------------- /src/auth/auth.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { ConfigService } from '@nestjs/config'; 3 | 4 | @Injectable() 5 | export class AuthService { 6 | private readonly apiKey; 7 | 8 | constructor(private readonly configService: ConfigService) { 9 | this.apiKey = configService.get('apiKey'); 10 | } 11 | 12 | validateApiKey(apiKey: string) { 13 | return this.apiKey === apiKey; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/auth/auth.middleware.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Injectable, 3 | NestMiddleware, 4 | UnauthorizedException, 5 | } from '@nestjs/common'; 6 | import * as passport from 'passport'; 7 | 8 | @Injectable() 9 | export class AuthMiddleware implements NestMiddleware { 10 | use(req: any, res: any, next: () => void) { 11 | passport.authenticate('headerapikey', (value) => { 12 | if (value) { 13 | next(); 14 | } else { 15 | throw new UnauthorizedException(); 16 | } 17 | })(req, res, next); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | pnpm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | 14 | # OS 15 | .DS_Store 16 | 17 | # Tests 18 | /coverage 19 | /.nyc_output 20 | 21 | # IDEs and editors 22 | /.idea 23 | .project 24 | .classpath 25 | .c9/ 26 | *.launch 27 | .settings/ 28 | *.sublime-workspace 29 | 30 | # IDE - VSCode 31 | .vscode/* 32 | !.vscode/settings.json 33 | !.vscode/tasks.json 34 | !.vscode/launch.json 35 | !.vscode/extensions.json 36 | 37 | .env 38 | -------------------------------------------------------------------------------- /src/users/schemas/user.schema.ts: -------------------------------------------------------------------------------- 1 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; 2 | import { Document, Model } from 'mongoose'; 3 | 4 | 5 | @Schema() 6 | class User { 7 | @Prop({ index: true, required: true }) 8 | email: string; 9 | 10 | @Prop() 11 | age: number; 12 | 13 | @Prop({ default: Date.now }) 14 | createdAt: Date; 15 | 16 | @Prop({ default: Date.now }) 17 | updatedAt: Date; 18 | } 19 | 20 | export type UserDocument = User & Document; 21 | 22 | export const UserSchema = SchemaFactory.createForClass(User); 23 | 24 | export type UserModel = Model; 25 | -------------------------------------------------------------------------------- /src/auth/auth.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { AuthService } from './auth.service'; 3 | import { ConfigModule } from '@nestjs/config'; 4 | 5 | describe('AuthService', () => { 6 | let service: AuthService; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | imports: [ConfigModule], 11 | providers: [AuthService, ConfigModule], 12 | }).compile(); 13 | 14 | service = module.get(AuthService); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(service).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "es2017", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true, 15 | "strictNullChecks": false, 16 | "noImplicitAny": false, 17 | "strictBindCallApply": false, 18 | "forceConsistentCasingInFileNames": false, 19 | "noFallthroughCasesInSwitch": false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/correlation-id.middleware.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response, NextFunction } from 'express'; 2 | import { Injectable, NestMiddleware } from '@nestjs/common'; 3 | import { randomUUID } from 'node:crypto'; 4 | 5 | export const CORRELATION_ID_KEY = 'X-Correlation-Id'; 6 | 7 | @Injectable() 8 | export class CorrelationIdMiddleware implements NestMiddleware { 9 | use(req: Request, res: Response, next: NextFunction) { 10 | const correlationHeader = req.header(CORRELATION_ID_KEY) || randomUUID(); 11 | req.headers[CORRELATION_ID_KEY] = correlationHeader; 12 | res.set(CORRELATION_ID_KEY, correlationHeader); 13 | 14 | next(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/auth/api-key.strategy.ts: -------------------------------------------------------------------------------- 1 | import { HeaderAPIKeyStrategy } from 'passport-headerapikey'; 2 | import { PassportStrategy } from '@nestjs/passport'; 3 | import { Injectable } from '@nestjs/common'; 4 | import { AuthService } from './auth.service'; 5 | 6 | @Injectable() 7 | export class ApiKeyStrategy extends PassportStrategy(HeaderAPIKeyStrategy) { 8 | constructor(private authService: AuthService) { 9 | super({ header: 'apiKey' }, true, (apikey, done) => { 10 | const checkKey = authService.validateApiKey(apikey); 11 | if (!checkKey) { 12 | return done(false); 13 | } 14 | return done(true); 15 | }); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/auth/auth.module.ts: -------------------------------------------------------------------------------- 1 | import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; 2 | import { AuthService } from './auth.service'; 3 | import { AuthMiddleware } from './auth.middleware'; 4 | import { PassportModule } from '@nestjs/passport'; 5 | import { ConfigModule } from '@nestjs/config'; 6 | import { ApiKeyStrategy } from './api-key.strategy'; 7 | 8 | @Module({ 9 | imports: [PassportModule, ConfigModule], 10 | providers: [AuthService, ApiKeyStrategy], 11 | }) 12 | export class AuthModule implements NestModule { 13 | configure(consumer: MiddlewareConsumer) { 14 | consumer.apply(AuthMiddleware).forRoutes('*'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | import { ValidationPipe } from '@nestjs/common'; 4 | import { Logger } from 'nestjs-pino'; 5 | import { ConfigService } from '@nestjs/config'; 6 | 7 | async function bootstrap() { 8 | const app = await NestFactory.create(AppModule); 9 | app.useLogger(app.get(Logger)); 10 | app.useGlobalPipes( 11 | new ValidationPipe({ 12 | whitelist: true, 13 | forbidNonWhitelisted: true, 14 | transform: true, 15 | }), 16 | ); 17 | const configService = app.get(ConfigService); 18 | const port = configService.get('port'); 19 | await app.listen(Number(port)); 20 | } 21 | bootstrap(); 22 | -------------------------------------------------------------------------------- /src/users/users.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { UsersService } from './users.service'; 3 | import { USER_REPOSITORY } from './user.repository'; 4 | 5 | describe('UsersService', () => { 6 | let service: UsersService; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | providers: [ 11 | UsersService, 12 | { 13 | provide: USER_REPOSITORY, 14 | useValue: {}, 15 | }, 16 | ], 17 | }).compile(); 18 | 19 | service = module.get(UsersService); 20 | }); 21 | 22 | it('should be defined', () => { 23 | expect(service).toBeDefined(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /test/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { INestApplication } from '@nestjs/common'; 3 | import * as request from 'supertest'; 4 | import { AppModule } from './../src/app.module'; 5 | 6 | describe('AppController (e2e)', () => { 7 | let app: INestApplication; 8 | 9 | beforeEach(async () => { 10 | const moduleFixture: TestingModule = await Test.createTestingModule({ 11 | imports: [AppModule], 12 | }).compile(); 13 | 14 | app = moduleFixture.createNestApplication(); 15 | await app.init(); 16 | }); 17 | 18 | it('/ (GET)', () => { 19 | return request(app.getHttpServer()) 20 | .get('/') 21 | .expect(200) 22 | .expect('Hello World!'); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | project: 'tsconfig.json', 5 | tsconfigRootDir : __dirname, 6 | sourceType: 'module', 7 | }, 8 | plugins: ['@typescript-eslint/eslint-plugin'], 9 | extends: [ 10 | 'plugin:@typescript-eslint/recommended', 11 | 'plugin:prettier/recommended', 12 | ], 13 | root: true, 14 | env: { 15 | node: true, 16 | jest: true, 17 | }, 18 | ignorePatterns: ['.eslintrc.js'], 19 | rules: { 20 | '@typescript-eslint/interface-name-prefix': 'off', 21 | '@typescript-eslint/explicit-function-return-type': 'off', 22 | '@typescript-eslint/explicit-module-boundary-types': 'off', 23 | '@typescript-eslint/no-explicit-any': 'off', 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /src/users/users.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { UsersController } from './users.controller'; 3 | import { UsersService } from './users.service'; 4 | 5 | describe('UsersController', () => { 6 | let controller: UsersController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [UsersController], 11 | providers: [ 12 | { 13 | provide: UsersService, 14 | useValue: {}, 15 | }, 16 | ], 17 | }).compile(); 18 | 19 | controller = module.get(UsersController); 20 | }); 21 | 22 | it('should be defined', () => { 23 | expect(controller).toBeDefined(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/logger/logger-options.ts: -------------------------------------------------------------------------------- 1 | import { CORRELATION_ID_KEY } from '../correlation-id.middleware'; 2 | 3 | export const loggerOptions = { 4 | pinoHttp: { 5 | transport: 6 | process.env.NODE_ENV !== 'production' 7 | ? { 8 | target: 'pino-pretty', 9 | options: { 10 | messageKey: 'message', 11 | }, 12 | } 13 | : undefined, 14 | messageKey: 'message', 15 | autoLogging: false, 16 | serializers: { 17 | req() { 18 | return undefined; 19 | }, 20 | res() { 21 | return undefined; 22 | }, 23 | }, 24 | customProps: function (req) { 25 | return { 26 | correlationId: req.headers[CORRELATION_ID_KEY], 27 | }; 28 | }, 29 | }, 30 | }; 31 | -------------------------------------------------------------------------------- /src/users/user.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UsersService } from './users.service'; 3 | import { UsersController } from './users.controller'; 4 | import { MongooseModule } from '@nestjs/mongoose'; 5 | import { User } from './entities/user.entity'; 6 | import { UserSchema } from './schemas/user.schema'; 7 | import { UserMongoRepository } from './user-mongo.repository'; 8 | import { USER_REPOSITORY } from './user.repository'; 9 | 10 | @Module({ 11 | imports: [ 12 | MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]), 13 | ], 14 | providers: [ 15 | UsersService, 16 | { 17 | provide: USER_REPOSITORY, 18 | useClass: UserMongoRepository, 19 | }, 20 | ], 21 | controllers: [UsersController], 22 | }) 23 | export class UserModule {} 24 | -------------------------------------------------------------------------------- /src/users/user-mongo.repository.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { CreateUserDto } from './dtos/create-user.dto'; 3 | import { InjectModel } from '@nestjs/mongoose'; 4 | import { User } from './entities/user.entity'; 5 | import { UserDocument, UserModel } from './schemas/user.schema'; 6 | import { UserRepository } from './user.repository'; 7 | 8 | @Injectable() 9 | export class UserMongoRepository implements UserRepository { 10 | constructor(@InjectModel(User.name) private userModel: UserModel) {} 11 | 12 | async findAll() { 13 | const users = await this.userModel.find().lean(); 14 | return users.map((user) => this.mapToUser(user)); 15 | } 16 | 17 | async createUser(createUserDto: CreateUserDto): Promise { 18 | const userCreated = await new this.userModel(createUserDto).save(); 19 | 20 | return this.mapToUser(userCreated); 21 | } 22 | 23 | private mapToUser(rawUser: UserDocument): User { 24 | const user = new User(); 25 | 26 | user.id = rawUser.id; 27 | user.email = rawUser.email; 28 | user.age = rawUser.age; 29 | user.createdAt = rawUser.createdAt; 30 | user.updatedAt = rawUser.updatedAt; 31 | 32 | return user; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/users/users.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Logger, NotFoundException } from '@nestjs/common'; 2 | import { CreateUserDto } from './dtos/create-user.dto'; 3 | import { USER_REPOSITORY, UserRepository } from './user.repository'; 4 | 5 | @Injectable() 6 | export class UsersService { 7 | private users = [{ name: 'albert', id: '1' }]; 8 | private readonly logger = new Logger(UsersService.name); 9 | 10 | constructor( 11 | @Inject(USER_REPOSITORY) private readonly userRepository: UserRepository, 12 | ) {} 13 | 14 | async findAll() { 15 | return this.userRepository.findAll(); 16 | } 17 | 18 | async findById(id: string) { 19 | const user = this.users.find((user) => user.id === id); 20 | 21 | if (!user) { 22 | throw new NotFoundException(`User not found ${id}`); 23 | } 24 | 25 | return user; 26 | } 27 | 28 | async createUser(createUserDto: CreateUserDto) { 29 | this.logger.log('Creating user in the users service'); 30 | return await this.userRepository.createUser(createUserDto); 31 | } 32 | 33 | async updateUser(updateUserDto: any, id: string) { 34 | return {}; 35 | } 36 | 37 | async deleteById(id: string) { 38 | return {}; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; 2 | import { LoggerModule } from 'nestjs-pino'; 3 | import { CorrelationIdMiddleware } from './correlation-id.middleware'; 4 | import { ConfigModule, ConfigService } from '@nestjs/config'; 5 | import { loggerOptions } from './logger/logger-options'; 6 | import { configOptions } from './config/config-options'; 7 | import { AuthModule } from './auth/auth.module'; 8 | import { UserModule } from './users/user.module'; 9 | import { MongooseModule } from '@nestjs/mongoose'; 10 | 11 | @Module({ 12 | imports: [ 13 | UserModule, 14 | LoggerModule.forRoot(loggerOptions), 15 | ConfigModule.forRoot(configOptions), 16 | AuthModule, 17 | MongooseModule.forRootAsync({ 18 | imports: [ConfigModule], 19 | useFactory: async (configService: ConfigService) => { 20 | const mongoConfig = configService.get('mongo'); 21 | 22 | return { 23 | uri: mongoConfig.uri, 24 | }; 25 | }, 26 | inject: [ConfigService], 27 | }), 28 | ], 29 | providers: [ 30 | ConfigModule, 31 | ], 32 | }) 33 | export class AppModule implements NestModule { 34 | configure(consumer: MiddlewareConsumer) { 35 | consumer.apply(CorrelationIdMiddleware).forRoutes('*'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/users/users.controller.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Body, 3 | Controller, 4 | Delete, 5 | Get, 6 | HttpException, 7 | HttpStatus, 8 | Logger, 9 | NotFoundException, 10 | Param, 11 | Patch, 12 | Post, 13 | } from '@nestjs/common'; 14 | import { UsersService } from './users.service'; 15 | import { CreateUserDto } from './dtos/create-user.dto'; 16 | 17 | @Controller('users') 18 | export class UsersController { 19 | private readonly logger = new Logger(UsersService.name); 20 | 21 | constructor(private readonly usersService: UsersService) {} 22 | 23 | @Get() 24 | async findAll() { 25 | return await this.usersService.findAll(); 26 | } 27 | 28 | @Get(':id') 29 | async findById(@Param('id') id: string) { 30 | return await this.usersService.findById(id); 31 | } 32 | 33 | @Post() 34 | async createUser(@Body() createUserDto: CreateUserDto) { 35 | this.logger.log('Received http request for creating a user'); 36 | const user = await this.usersService.createUser(createUserDto); 37 | this.logger.log('Finalized http request for creating a user'); 38 | return user; 39 | } 40 | 41 | @Patch(':id') 42 | async updateUser(@Body() updateUserDto: any, @Param('id') id: string) { 43 | return await this.usersService.updateUser(updateUserDto, id); 44 | } 45 | 46 | @Delete(':id') 47 | async deleteById(@Param('id') id: string) { 48 | return await this.usersService.deleteById(id); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "users-crud", 3 | "version": "0.0.1", 4 | "description": "", 5 | "author": "", 6 | "private": true, 7 | "license": "UNLICENSED", 8 | "scripts": { 9 | "prebuild": "rimraf dist", 10 | "build": "nest build", 11 | "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", 12 | "start": "nest start", 13 | "start:dev": "nest start --watch", 14 | "start:debug": "nest start --debug --watch", 15 | "start:prod": "node dist/main", 16 | "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", 17 | "test": "jest", 18 | "test:watch": "jest --watch", 19 | "test:cov": "jest --coverage", 20 | "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", 21 | "test:e2e": "jest --config ./test/jest-e2e.json" 22 | }, 23 | "dependencies": { 24 | "@nestjs/common": "^10.0.0", 25 | "@nestjs/config": "^3.1.1", 26 | "@nestjs/core": "^10.0.0", 27 | "@nestjs/mongoose": "^10.0.0", 28 | "@nestjs/passport": "^10.0.0", 29 | "@nestjs/platform-express": "^10.0.0", 30 | "@types/passport-local": "^1.0.34", 31 | "class-transformer": "^0.5.1", 32 | "class-validator": "^0.14.0", 33 | "joi": "^17.6.0", 34 | "mongoose": "^8.0.3", 35 | "nestjs-pino": "^3.5.0", 36 | "passport": "^0.7.0", 37 | "passport-headerapikey": "^1.2.2", 38 | "passport-local": "^1.0.0", 39 | "pino-http": "^8.2.0", 40 | "pino-pretty": "^10.3.0", 41 | "reflect-metadata": "^0.1.13", 42 | "rimraf": "^5.0.5", 43 | "rxjs": "^7.8.1" 44 | }, 45 | "devDependencies": { 46 | "@nestjs/cli": "^10.2.1", 47 | "@nestjs/schematics": "^10.0.3", 48 | "@nestjs/testing": "^10.3.0", 49 | "@types/express": "^4.17.21", 50 | "@types/jest": "^29.5.11", 51 | "@types/node": "^20.10.6", 52 | "@types/supertest": "^2.0.12", 53 | "@typescript-eslint/eslint-plugin": "^6.16.0", 54 | "@typescript-eslint/parser": "^6.16.0", 55 | "eslint": "^8.42.0", 56 | "eslint-config-prettier": "^9.1.0", 57 | "eslint-plugin-prettier": "^5.1.2", 58 | "jest": "^29.7.0", 59 | "prettier": "^3.1.1", 60 | "source-map-support": "^0.5.21", 61 | "supertest": "^6.3.3", 62 | "ts-jest": "^29.1.1", 63 | "ts-loader": "^9.4.4", 64 | "ts-node": "^10.9.0", 65 | "tsconfig-paths": "4.2.0", 66 | "typescript": "^5.3.3" 67 | }, 68 | "jest": { 69 | "moduleFileExtensions": [ 70 | "js", 71 | "json", 72 | "ts" 73 | ], 74 | "rootDir": "src", 75 | "testRegex": ".*\\.spec\\.ts$", 76 | "transform": { 77 | "^.+\\.(t|j)s$": "ts-jest" 78 | }, 79 | "collectCoverageFrom": [ 80 | "**/*.(t|j)s" 81 | ], 82 | "coverageDirectory": "../coverage", 83 | "testEnvironment": "node" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Nest Logo 3 |

4 | 5 | [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 6 | [circleci-url]: https://circleci.com/gh/nestjs/nest 7 | 8 |

A progressive Node.js framework for building efficient and scalable server-side applications.

9 |

10 | NPM Version 11 | Package License 12 | NPM Downloads 13 | CircleCI 14 | Coverage 15 | Discord 16 | Backers on Open Collective 17 | Sponsors on Open Collective 18 | 19 | Support us 20 | 21 |

22 | 24 | 25 | ## Description 26 | 27 | [Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. 28 | 29 | ## Installation 30 | 31 | ```bash 32 | $ npm install 33 | ``` 34 | 35 | ## Running the app 36 | 37 | ```bash 38 | # development 39 | $ npm run start 40 | 41 | # watch mode 42 | $ npm run start:dev 43 | 44 | # production mode 45 | $ npm run start:prod 46 | ``` 47 | 48 | ## Test 49 | 50 | ```bash 51 | # unit tests 52 | $ npm run test 53 | 54 | # e2e tests 55 | $ npm run test:e2e 56 | 57 | # test coverage 58 | $ npm run test:cov 59 | ``` 60 | 61 | ## Support 62 | 63 | Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). 64 | 65 | ## Stay in touch 66 | 67 | - Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) 68 | - Website - [https://nestjs.com](https://nestjs.com/) 69 | - Twitter - [@nestframework](https://twitter.com/nestframework) 70 | 71 | ## License 72 | 73 | Nest is [MIT licensed](LICENSE). 74 | --------------------------------------------------------------------------------