<project version="4"> | <project version="4"> | ||||
<component name="VcsDirectoryMappings"> | <component name="VcsDirectoryMappings"> | ||||
<mapping directory="$PROJECT_DIR$" vcs="Git" /> | <mapping directory="$PROJECT_DIR$" vcs="Git" /> | ||||
<mapping directory="$PROJECT_DIR$/server" vcs="Git" /> | |||||
</component> | </component> | ||||
</project> | </project> |
module.exports = { | |||||
parser: '@typescript-eslint/parser', | |||||
parserOptions: { | |||||
project: 'tsconfig.json', | |||||
sourceType: 'module', | |||||
}, | |||||
plugins: ['@typescript-eslint/eslint-plugin'], | |||||
extends: [ | |||||
'plugin:@typescript-eslint/recommended', | |||||
'plugin:prettier/recommended', | |||||
], | |||||
root: true, | |||||
env: { | |||||
node: true, | |||||
jest: true, | |||||
}, | |||||
ignorePatterns: ['.eslintrc.js'], | |||||
rules: { | |||||
'@typescript-eslint/interface-name-prefix': 'off', | |||||
'@typescript-eslint/explicit-function-return-type': 'off', | |||||
'@typescript-eslint/explicit-module-boundary-types': 'off', | |||||
'@typescript-eslint/no-explicit-any': 'off', | |||||
}, | |||||
}; |
# compiled output | |||||
/dist | |||||
/node_modules | |||||
# Logs | |||||
logs | |||||
*.log | |||||
npm-debug.log* | |||||
yarn-debug.log* | |||||
yarn-error.log* | |||||
lerna-debug.log* | |||||
# OS | |||||
.DS_Store | |||||
# Tests | |||||
/coverage | |||||
/.nyc_output | |||||
# IDEs and editors | |||||
/.idea | |||||
.project | |||||
.classpath | |||||
.c9/ | |||||
*.launch | |||||
.settings/ | |||||
*.sublime-workspace | |||||
# IDE - VSCode | |||||
.vscode/* | |||||
!.vscode/settings.json | |||||
!.vscode/tasks.json | |||||
!.vscode/launch.json | |||||
!.vscode/extensions.json |
{ | |||||
"singleQuote": true, | |||||
"trailingComma": "all" | |||||
} |
## Description | |||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. | |||||
## Installation | |||||
```bash | |||||
$ npm install | |||||
``` | |||||
## Running the app | |||||
```bash | |||||
# development | |||||
$ npm run start | |||||
# watch mode | |||||
$ npm run start:dev | |||||
# production mode | |||||
$ npm run start:prod | |||||
``` | |||||
## Test | |||||
```bash | |||||
# unit tests | |||||
$ npm run test | |||||
# e2e tests | |||||
$ npm run test:e2e | |||||
# test coverage | |||||
$ npm run test:cov | |||||
``` | |||||
## Support | |||||
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). | |||||
## Stay in touch | |||||
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) | |||||
- Website - [https://nestjs.com](https://nestjs.com/) | |||||
- Twitter - [@nestframework](https://twitter.com/nestframework) | |||||
## License |
{ | |||||
"collection": "@nestjs/schematics", | |||||
"sourceRoot": "src" | |||||
} |
{ | |||||
"name": "server", | |||||
"version": "0.0.1", | |||||
"description": "", | |||||
"author": "", | |||||
"private": true, | |||||
"license": "UNLICENSED", | |||||
"scripts": { | |||||
"prebuild": "rimraf dist", | |||||
"build": "nest build", | |||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", | |||||
"start": "nest start", | |||||
"start:dev": "nest start --watch", | |||||
"start:debug": "nest start --debug --watch", | |||||
"start:prod": "node dist/main", | |||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", | |||||
"test": "jest", | |||||
"test:watch": "jest --watch", | |||||
"test:cov": "jest --coverage", | |||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", | |||||
"test:e2e": "jest --config ./test/jest-e2e.json" | |||||
}, | |||||
"dependencies": { | |||||
"@nestjs/common": "^7.6.15", | |||||
"@nestjs/core": "^7.6.15", | |||||
"@nestjs/platform-express": "^7.6.15", | |||||
"reflect-metadata": "^0.1.13", | |||||
"rimraf": "^3.0.2", | |||||
"rxjs": "^6.6.6" | |||||
}, | |||||
"devDependencies": { | |||||
"@nestjs/cli": "^7.6.0", | |||||
"@nestjs/schematics": "^7.3.0", | |||||
"@nestjs/testing": "^7.6.15", | |||||
"@types/express": "^4.17.11", | |||||
"@types/jest": "^26.0.22", | |||||
"@types/node": "^14.14.36", | |||||
"@types/supertest": "^2.0.10", | |||||
"@typescript-eslint/eslint-plugin": "^4.19.0", | |||||
"@typescript-eslint/parser": "^4.19.0", | |||||
"eslint": "^7.22.0", | |||||
"eslint-config-prettier": "^8.1.0", | |||||
"eslint-plugin-prettier": "^3.3.1", | |||||
"jest": "^26.6.3", | |||||
"prettier": "^2.2.1", | |||||
"supertest": "^6.1.3", | |||||
"ts-jest": "^26.5.4", | |||||
"ts-loader": "^8.0.18", | |||||
"ts-node": "^9.1.1", | |||||
"tsconfig-paths": "^3.9.0", | |||||
"typescript": "^4.2.3" | |||||
}, | |||||
"jest": { | |||||
"moduleFileExtensions": [ | |||||
"js", | |||||
"json", | |||||
"ts" | |||||
], | |||||
"rootDir": "src", | |||||
"testRegex": ".*\\.spec\\.ts$", | |||||
"transform": { | |||||
"^.+\\.(t|j)s$": "ts-jest" | |||||
}, | |||||
"collectCoverageFrom": [ | |||||
"**/*.(t|j)s" | |||||
], | |||||
"coverageDirectory": "../coverage", | |||||
"testEnvironment": "node" | |||||
} | |||||
} |
import { Test, TestingModule } from '@nestjs/testing'; | |||||
import { AppController } from './app.controller'; | |||||
import { AppService } from './app.service'; | |||||
describe('AppController', () => { | |||||
let appController: AppController; | |||||
beforeEach(async () => { | |||||
const app: TestingModule = await Test.createTestingModule({ | |||||
controllers: [AppController], | |||||
providers: [AppService], | |||||
}).compile(); | |||||
appController = app.get<AppController>(AppController); | |||||
}); | |||||
describe('root', () => { | |||||
it('should return "Hello World!"', () => { | |||||
expect(appController.getHello()).toBe('Hello World!'); | |||||
}); | |||||
}); | |||||
}); |
import { Controller, Get } from '@nestjs/common'; | |||||
import { AppService } from './app.service'; | |||||
@Controller() | |||||
export class AppController { | |||||
constructor(private readonly appService: AppService) {} | |||||
@Get() | |||||
getHello(): string { | |||||
return this.appService.getHello(); | |||||
} | |||||
} |
import { Module } from '@nestjs/common'; | |||||
import { AppController } from './app.controller'; | |||||
import { AppService } from './app.service'; | |||||
@Module({ | |||||
imports: [], | |||||
controllers: [AppController], | |||||
providers: [AppService], | |||||
}) | |||||
export class AppModule {} |
import { Injectable } from '@nestjs/common'; | |||||
@Injectable() | |||||
export class AppService { | |||||
getHello(): string { | |||||
return 'Hello World!'; | |||||
} | |||||
} |
import { NestFactory } from '@nestjs/core'; | |||||
import { AppModule } from './app.module'; | |||||
async function bootstrap() { | |||||
const app = await NestFactory.create(AppModule); | |||||
await app.listen(3000); | |||||
} | |||||
bootstrap(); |
import { Test, TestingModule } from '@nestjs/testing'; | |||||
import { INestApplication } from '@nestjs/common'; | |||||
import * as request from 'supertest'; | |||||
import { AppModule } from '../src/app.module'; | |||||
describe('AppController (e2e)', () => { | |||||
let app: INestApplication; | |||||
beforeEach(async () => { | |||||
const moduleFixture: TestingModule = await Test.createTestingModule({ | |||||
imports: [AppModule], | |||||
}).compile(); | |||||
app = moduleFixture.createNestApplication(); | |||||
await app.init(); | |||||
}); | |||||
it('/ (GET)', () => { | |||||
return request(app.getHttpServer()) | |||||
.get('/') | |||||
.expect(200) | |||||
.expect('Hello World!'); | |||||
}); | |||||
}); |
{ | |||||
"moduleFileExtensions": ["js", "json", "ts"], | |||||
"rootDir": ".", | |||||
"testEnvironment": "node", | |||||
"testRegex": ".e2e-spec.ts$", | |||||
"transform": { | |||||
"^.+\\.(t|j)s$": "ts-jest" | |||||
} | |||||
} |
{ | |||||
"extends": "./tsconfig.json", | |||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"] | |||||
} |
{ | |||||
"compilerOptions": { | |||||
"module": "commonjs", | |||||
"declaration": true, | |||||
"removeComments": true, | |||||
"emitDecoratorMetadata": true, | |||||
"experimentalDecorators": true, | |||||
"allowSyntheticDefaultImports": true, | |||||
"target": "es2017", | |||||
"sourceMap": true, | |||||
"outDir": "./dist", | |||||
"baseUrl": "./", | |||||
"incremental": true | |||||
} | |||||
} |