sample() update samples

This commit is contained in:
Kamil Myśliwiec
2019-10-11 10:29:51 +02:00
99 changed files with 130278 additions and 405 deletions

View File

@@ -4,35 +4,62 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main.ts", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js", "start": "nest start",
"test": "jest --config=jest.json", "start:dev": "nest start --watch",
"test:watch": "jest --watch --config=jest.json", "start:debug": "nest start --debug --watch",
"test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage", "start:prod": "node dist/main",
"e2e": "jest --config=e2e/jest-e2e.json --forceExit", "lint": "tslint -p tsconfig.json -c tslint.json",
"e2e:watch": "jest --watch --config=e2e/jest-e2e.json" "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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "^6.8.0",
"@nestjs/core": "6.8.2", "@nestjs/core": "^6.8.0",
"@nestjs/platform-express": "6.8.2", "@nestjs/platform-express": "^6.8.0",
"@nestjs/testing": "6.8.2", "reflect-metadata": "^0.1.13",
"@nestjs/websockets": "6.8.2",
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"reflect-metadata": "0.1.13", "rimraf": "^3.0.0",
"rxjs": "6.5.3", "rxjs": "^6.5.3"
"typescript": "3.6.4"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "24.0.18", "@nestjs/cli": "^6.10.1",
"@types/node": "10.14.21", "@nestjs/schematics": "^6.7.0",
"jest": "24.9.0", "@nestjs/testing": "^6.8.0",
"supertest": "4.0.2", "@types/express": "^4.17.1",
"ts-jest": "24.1.0", "@types/node": "^12.7.8",
"ts-node": "8.4.1", "@types/supertest": "^2.0.8",
"tslint": "5.20.0" "jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.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"
} }
} }

View File

@@ -4,4 +4,4 @@ import { CatsModule } from './cats/cats.module';
@Module({ @Module({
imports: [CatsModule], imports: [CatsModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,9 +1,9 @@
import { ValidationPipe } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe()); app.useGlobalPipes(new ValidationPipe());
await app.listen(3000); await app.listen(3000);
} }

View File

@@ -4,31 +4,51 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main.ts", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2", "@nestjs/core": "6.8.2",
"@nestjs/platform-express": "6.8.2", "@nestjs/platform-express": "6.8.2",
"@nestjs/platform-socket.io": "6.8.2", "@nestjs/platform-socket.io": "6.8.2",
"@nestjs/testing": "6.8.2",
"@nestjs/websockets": "6.8.2", "@nestjs/websockets": "6.8.2",
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3", "rxjs": "6.5.3",
"socket.io-redis": "5.2.0", "socket.io-redis": "5.2.0"
"typescript": "3.6.4"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "7.10.7", "@types/socket.io": "2.1.3",
"@types/socket.io": "2.1.4",
"@types/socket.io-redis": "1.0.25", "@types/socket.io-redis": "1.0.25",
"@types/ws": "6.0.3", "@types/ws": "6.0.3",
"ts-node": "8.4.1", "@nestjs/cli": "^6.9.1",
"tslint": "5.20.0" "@nestjs/schematics": "^6.7.0",
"@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { EventsModule } from './events/events.module';
@Module({ @Module({
imports: [EventsModule], imports: [EventsModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); bootstrap();

10231
sample/03-microservices/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,27 +4,47 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main.ts", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2", "@nestjs/core": "6.8.2",
"@nestjs/microservices": "6.8.2", "@nestjs/microservices": "6.8.2",
"@nestjs/platform-express": "6.8.2", "@nestjs/platform-express": "6.8.2",
"@nestjs/testing": "6.8.2",
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/cli": "^6.9.1",
"@nestjs/schematics": "^6.7.0",
"@nestjs/testing": "^6.8.0",
"@types/amqplib": "0.5.13", "@types/amqplib": "0.5.13",
"@types/node": "10.14.21", "@types/express": "^4.17.1",
"ts-node": "8.4.1", "@types/node": "^12.7.8",
"tslint": "5.20.0" "@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { MathModule } from './math/math.module';
@Module({ @Module({
imports: [MathModule], imports: [MathModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,20 +1,20 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { Transport } from '@nestjs/microservices'; import { Transport } from '@nestjs/microservices';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
/** /**
* Hybrid application (HTTP + TCP) * Hybrid application (HTTP + TCP)
* Switch to basic microservice with NestFactory.createMicroservice(): * Switch to basic microservice with NestFactory.createMicroservice():
* *
* const app = await NestFactory.createMicroservice(ApplicationModule, { * const app = await NestFactory.createMicroservice(AppModule, {
* transport: Transport.TCP, * transport: Transport.TCP,
* options: { retryAttempts: 5, retryDelay: 3000 }, * options: { retryAttempts: 5, retryDelay: 3000 },
* }); * });
* await app.listenAsync(); * await app.listenAsync();
* *
*/ */
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.connectMicroservice({ app.connectMicroservice({
transport: Transport.TCP, transport: Transport.TCP,
options: { retryAttempts: 5, retryDelay: 3000 }, options: { retryAttempts: 5, retryDelay: 3000 },

View File

@@ -4,27 +4,48 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main.ts", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@grpc/proto-loader": "0.5.2", "@grpc/proto-loader": "0.5.2",
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2", "@nestjs/core": "6.8.2",
"@nestjs/microservices": "6.8.2", "@nestjs/microservices": "6.8.2",
"@nestjs/testing": "6.8.2",
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"grpc": "1.24.0", "grpc": "1.24.0",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"@types/ws": "6.0.3",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { HeroModule } from './hero/hero.module';
@Module({ @Module({
imports: [HeroModule], imports: [HeroModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,5 +1,5 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
import { grpcClientOptions } from './grpc-client.options'; import { grpcClientOptions } from './grpc-client.options';
async function bootstrap() { async function bootstrap() {
@@ -7,7 +7,7 @@ async function bootstrap() {
* Hybrid application (HTTP + GRPC) * Hybrid application (HTTP + GRPC)
* Switch to basic microservice with NestFactory.createMicroservice(): * Switch to basic microservice with NestFactory.createMicroservice():
* *
* const app = await NestFactory.createMicroservice(ApplicationModule, { * const app = await NestFactory.createMicroservice(AppModule, {
* transport: Transport.GRPC, * transport: Transport.GRPC,
* options: { * options: {
* package: 'hero', * package: 'hero',
@@ -17,7 +17,7 @@ async function bootstrap() {
* await app.listenAsync(); * await app.listenAsync();
* *
*/ */
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.connectMicroservice(grpcClientOptions); app.connectMicroservice(grpcClientOptions);
await app.startAllMicroservicesAsync(); await app.startAllMicroservicesAsync();
await app.listen(3001); await app.listen(3001);

View File

@@ -0,0 +1,27 @@
### SQL TypeORM sample
### Installation
`npm install`
### Running
This example requires docker or a local MySQL installation. If using a local MySQL database, see `app.module.ts` for credentials, and make sure there are matching credentials in the database and the source code.
#### Docker
There is a `docker-compose.yml` file for starting Docker.
`docker-compose up`
After running the sample, you can stop the Docker container with
`docker-compose down`
### Run the sample
Then, run Nest as usual:
`npm run start`

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -16,13 +25,26 @@
"@nestjs/typeorm": "6.2.0", "@nestjs/typeorm": "6.2.0",
"mysql": "2.17.1", "mysql": "2.17.1",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3", "rxjs": "6.5.3",
"typeorm": "0.2.19", "typeorm": "0.2.19"
"typescript": "3.6.4"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "7.10.7", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"@types/ws": "6.0.3",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -18,4 +18,4 @@ import { PhotoModule } from './photo/photo.module';
PhotoModule, PhotoModule,
], ],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3001); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -0,0 +1,27 @@
### Mongoose sample
### Installation
`npm install`
### Running
This example requires docker or a local mongodb installation. If using a local mongodb, see `app.module.ts` for connection options, and make sure there are matching options for the mongodb installation and the source code.
#### Docker
There is a `docker-compose.yml` file for starting Docker.
`docker-compose up`
After running the sample, you can stop the Docker container with
`docker-compose down`
### Run the sample
Then, run Nest as usual:
`npm run start`

10305
sample/06-mongoose/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -16,13 +25,26 @@
"@nestjs/mongoose": "6.1.2", "@nestjs/mongoose": "6.1.2",
"mongoose": "5.7.4", "mongoose": "5.7.4",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/mongoose": "5.5.20", "@types/mongoose": "5.5.19",
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"@types/ws": "6.0.3",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -8,4 +8,4 @@ import { CatsModule } from './cats/cats.module';
CatsModule, CatsModule,
], ],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3001); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -0,0 +1,26 @@
### Sequelize sample
### Installation
`npm install`
### Running
This example requires docker or a local MySQL installation. If using a local MySQL database, see `database/database.providers.ts` for credentials, and make sure there are matching credentials in the database and the source code.
#### Docker
There is a `docker-compose.yml` file for starting Docker.
`docker-compose up`
After running the sample, you can stop the Docker container with
`docker-compose down`
### Run the sample
Then, run Nest as usual:
`npm run start`

10523
sample/07-sequelize/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -15,15 +24,29 @@
"@nestjs/platform-express": "6.8.2", "@nestjs/platform-express": "6.8.2",
"mysql2": "1.7.0", "mysql2": "1.7.0",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3", "rxjs": "6.5.3",
"sequelize": "5.19.5", "sequelize": "5.19.5",
"sequelize-typescript": "1.0.0", "sequelize-typescript": "1.0.0",
"typescript": "3.6.4" "typescript": "3.6.4"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21",
"@types/sequelize": "4.28.5", "@types/sequelize": "4.28.5",
"ts-node": "8.4.1", "@nestjs/cli": "^6.9.1",
"tslint": "5.20.0" "@nestjs/schematics": "^6.7.0",
"@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"@types/ws": "6.0.3",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { CatsModule } from './cats/cats.module';
@Module({ @Module({
imports: [CatsModule], imports: [CatsModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3001); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -4,9 +4,8 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"start": "node dist/server", "build": "nest build --watch --webpack",
"dev": "webpack --config webpack.config.js --watch", "start": "node dist/main"
"build": "webpack --config webpack.config.js"
}, },
"dependencies": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",

View File

@@ -7,4 +7,4 @@ import { AppService } from './app.service';
controllers: [AppController], controllers: [AppController],
providers: [AppService], providers: [AppService],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,10 +1,10 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
declare const module: any; declare const module: any;
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3000); await app.listen(3000);
if (module.hot) { if (module.hot) {

View File

@@ -1,31 +1,16 @@
const webpack = require('webpack'); const webpack = require('webpack');
const path = require('path');
const nodeExternals = require('webpack-node-externals'); const nodeExternals = require('webpack-node-externals');
module.exports = { module.exports = function(options) {
return {
...options,
entry: ['webpack/hot/poll?100', './src/main.ts'], entry: ['webpack/hot/poll?100', './src/main.ts'],
target: 'node', watch: true,
externals: [ externals: [
nodeExternals({ nodeExternals({
whitelist: ['webpack/hot/poll?100'], whitelist: ['webpack/hot/poll?100'],
}), }),
], ],
module: { plugins: [...options.plugins, new webpack.HotModuleReplacementPlugin()],
rules: [ };
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
mode: 'development',
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [new webpack.HotModuleReplacementPlugin(), new webpack.WatchIgnorePlugin([/\.js$/, /\.d\.ts$/])],
output: {
path: path.join(__dirname, 'dist'),
filename: 'server.js',
},
}; };

View File

@@ -1,4 +1,12 @@
{ {
"presets": ["env", "stage-0"], "presets": ["@babel/preset-env"],
"plugins": ["transform-decorators-legacy"] "plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
]
} }

View File

@@ -1,3 +1,2 @@
require('babel-core/register'); require('@babel/register');
require('babel-polyfill');
require('./src/main'); require('./src/main');

View File

@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": "js",
"ignore": ["src/**/*.spec.js"],
"exec": "node index --exec babel-node"
}

4458
sample/09-babel-example/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,26 +4,43 @@
"description": "Nest Babel starter repository", "description": "Nest Babel starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "babel src -d dist", "format": "prettier --write \"**/*.js\"",
"prestart": "npm run build", "start": "babel-node index.js",
"start": "node index.js" "start:dev": "nodemon",
"test": "jest",
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json"
}, },
"dependencies": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "^6.7.2",
"@nestjs/core": "6.8.2", "@nestjs/core": "^6.7.2",
"@nestjs/microservices": "6.8.2", "@nestjs/platform-express": "^6.7.2",
"@nestjs/platform-express": "6.8.2", "@nestjs/microservices": "^6.7.2",
"@nestjs/testing": "6.8.2", "@nestjs/websockets": "^6.7.2",
"@nestjs/websockets": "6.8.2", "reflect-metadata": "^0.1.13",
"babel-core": "6.26.3", "rxjs": "^6.5.3"
"babel-polyfill": "6.26.0",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"babel-cli": "6.26.0", "@babel/core": "^7.6.2",
"babel-plugin-transform-decorators-legacy": "1.3.5", "@babel/node": "^7.6.2",
"babel-preset-env": "1.7.0", "@babel/plugin-proposal-decorators": "^7.6.0",
"babel-preset-stage-0": "6.24.1" "@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.6.2",
"@babel/register": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@nestjs/testing": "^6.7.2",
"jest": "^24.9.0",
"nodemon": "^1.19.2",
"prettier": "^1.18.2",
"supertest": "^4.0.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json"
],
"rootDir": "src",
"testRegex": ".spec.js$",
"coverageDirectory": "../coverage"
} }
} }

View File

@@ -4,4 +4,4 @@ import { CatsModule } from './cats/cats.module';
@Module({ @Module({
imports: [CatsModule], imports: [CatsModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,11 +1,8 @@
require('babel-core/register');
require('babel-polyfill');
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -0,0 +1,5 @@
### Fastify sample
Note that if you are running the Nest app on a remote machine, you may need to change the listen address, as per [these instructions](https://docs.nestjs.com/techniques/performance#adapter):
`await app.listen(3000, '0.0.0.0')`

10169
sample/10-fastify/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -16,12 +25,25 @@
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"@types/ws": "6.0.3",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { CatsModule } from './cats/cats.module';
@Module({ @Module({
imports: [CatsModule], imports: [CatsModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -4,11 +4,11 @@ import {
FastifyAdapter, FastifyAdapter,
NestFastifyApplication, NestFastifyApplication,
} from '@nestjs/platform-fastify'; } from '@nestjs/platform-fastify';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>( const app = await NestFactory.create<NestFastifyApplication>(
ApplicationModule, AppModule,
new FastifyAdapter(), new FastifyAdapter(),
); );
app.useGlobalPipes(new ValidationPipe()); app.useGlobalPipes(new ValidationPipe());

View File

@@ -0,0 +1,11 @@
### Swagger sample
### Installation
`npm install`
### Running
Once the application is running you can visit [http://localhost:3000/api](http://localhost:3000/api) to see the Swagger interface.
See [here](https://docs.nestjs.com/recipes/swagger#bootstrap) for more information.

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -17,14 +26,25 @@
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3", "rxjs": "6.5.3",
"swagger-ui-express": "4.1.2", "swagger-ui-express": "4.1.1"
"typescript": "3.6.4"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"supertest": "4.0.2", "@nestjs/schematics": "^6.7.0",
"ts-node": "8.4.1", "@nestjs/testing": "^6.8.0",
"tslint": "5.20.0" "@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { CatsModule } from './cats/cats.module';
@Module({ @Module({
imports: [CatsModule], imports: [CatsModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,9 +1,9 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
const options = new DocumentBuilder() const options = new DocumentBuilder()
.setTitle('Cats example') .setTitle('Cats example')
@@ -15,6 +15,6 @@ async function bootstrap() {
const document = SwaggerModule.createDocument(app, options); const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document); SwaggerModule.setup('api', app, document);
await app.listen(3001); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -0,0 +1,9 @@
### Graphql Apollo sample
### Installation
`npm install`
### Graphql Playground
When the application is running, you can go to [http://localhost:3000/graphql](http://localhost:3000/graphql) to access the GraphQL Playground. See [here](https://docs.nestjs.com/graphql/quick-start#playground) for more.

12015
sample/12-graphql-apollo/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -20,12 +29,24 @@
"graphql": "14.5.8", "graphql": "14.5.8",
"graphql-subscriptions": "1.1.0", "graphql-subscriptions": "1.1.0",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -11,4 +11,4 @@ import { CatsModule } from './cats/cats.module';
}), }),
], ],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,9 +1,9 @@
import { ValidationPipe } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe()); app.useGlobalPipes(new ValidationPipe());
await app.listen(3000); await app.listen(3000);
} }

View File

@@ -0,0 +1,26 @@
### Mongoose sample
### Installation
`npm install`
### Running
This example requires docker or a local mongodb installation. If using a local mongodb, see `app.module.ts` for connection options, and make sure there are matching options for the mongodb installation and the source code.
#### Docker
There is a `docker-compose.yml` file for starting Docker.
`docker-compose up`
After running the sample, you can stop the Docker container with
`docker-compose down`
### Run the sample
Then, run Nest as usual:
`npm run start`

10157
sample/13-mongo-typeorm/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -16,13 +25,25 @@
"@nestjs/typeorm": "6.2.0", "@nestjs/typeorm": "6.2.0",
"mongodb": "3.3.2", "mongodb": "3.3.2",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3", "rxjs": "6.5.3",
"typeorm": "0.2.19", "typeorm": "0.2.19"
"typescript": "3.6.4"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -16,4 +16,4 @@ import { Photo } from './photo/photo.entity';
PhotoModule, PhotoModule,
], ],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3001); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -0,0 +1,26 @@
### Mongoose base sample
### Installation
`npm install`
### Running
This example requires docker or a local mongodb installation. If using a local mongodb, see `app.module.ts` for connection options, and make sure there are matching options for the mongodb installation and the source code.
#### Docker
There is a `docker-compose.yml` file for starting Docker.
`docker-compose up`
After running the sample, you can stop the Docker container with
`docker-compose down`
### Run the sample
Then, run Nest as usual:
`npm run start`

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -15,13 +24,25 @@
"@nestjs/platform-express": "6.8.2", "@nestjs/platform-express": "6.8.2",
"mongoose": "5.7.4", "mongoose": "5.7.4",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/mongoose": "5.5.20", "@types/mongoose": "5.5.19",
"@types/node": "7.10.7", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { CatsModule } from './cats/cats.module';
@Module({ @Module({
imports: [CatsModule], imports: [CatsModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3001); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -16,13 +25,24 @@
"hbs": "4.0.6", "hbs": "4.0.6",
"pug": "2.0.4", "pug": "2.0.4",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "8.10.54", "@nestjs/cli": "^6.9.1",
"nodemon": "1.19.3", "@nestjs/schematics": "^6.7.0",
"ts-node": "8.4.1", "@nestjs/testing": "^6.8.0",
"tslint": "5.20.0" "@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -6,4 +6,4 @@ import { AppController } from './app.controller';
controllers: [AppController], controllers: [AppController],
providers: [], providers: [],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,12 +1,10 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express'; import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path'; import { join } from 'path';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>( const app = await NestFactory.create<NestExpressApplication>(AppModule);
ApplicationModule,
);
app.useStaticAssets(join(__dirname, '..', 'public')); app.useStaticAssets(join(__dirname, '..', 'public'));
app.setBaseViewsDir(join(__dirname, '..', 'views')); app.setBaseViewsDir(join(__dirname, '..', 'views'));

10233
sample/16-gateways-ws/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -17,15 +26,27 @@
"@nestjs/websockets": "6.8.2", "@nestjs/websockets": "6.8.2",
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"rimraf": "^3.0.0",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rxjs": "6.5.3",
"typescript": "3.6.4",
"ws": "7.1.2" "ws": "7.1.2"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21",
"@types/ws": "6.0.3", "@types/ws": "6.0.3",
"ts-node": "8.4.1", "@nestjs/cli": "^6.9.1",
"tslint": "5.20.0" "@nestjs/schematics": "^6.7.0",
"@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { EventsModule } from './events/events.module';
@Module({ @Module({
imports: [EventsModule], imports: [EventsModule],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,9 +1,9 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { WsAdapter } from '@nestjs/platform-ws'; import { WsAdapter } from '@nestjs/platform-ws';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.useWebSocketAdapter(new WsAdapter(app)); app.useWebSocketAdapter(new WsAdapter(app));
await app.listen(3000); await app.listen(3000);
} }

View File

@@ -0,0 +1,5 @@
### Fastify MVC sample
Note that if you are running the Nest app on a remote machine, you may need to change the listen address, as per [these instructions](https://docs.nestjs.com/techniques/performance#adapter):
`await app.listen(3000, '0.0.0.0')`

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -16,13 +25,27 @@
"handlebars": "4.4.3", "handlebars": "4.4.3",
"point-of-view": "3.5.2", "point-of-view": "3.5.2",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "8.10.54", "@types/socket.io": "2.1.3",
"nodemon": "1.19.3", "@types/socket.io-redis": "1.0.25",
"ts-node": "8.4.1", "@types/ws": "6.0.3",
"tslint": "5.20.0" "@nestjs/cli": "^6.9.1",
"@nestjs/schematics": "^6.7.0",
"@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -6,4 +6,4 @@ import { AppController } from './app.controller';
controllers: [AppController], controllers: [AppController],
providers: [], providers: [],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -4,11 +4,11 @@ import {
NestFastifyApplication, NestFastifyApplication,
} from '@nestjs/platform-fastify'; } from '@nestjs/platform-fastify';
import { join } from 'path'; import { join } from 'path';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>( const app = await NestFactory.create<NestFastifyApplication>(
ApplicationModule, AppModule,
new FastifyAdapter(), new FastifyAdapter(),
); );
app.useStaticAssets({ app.useStaticAssets({

9691
sample/18-context/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,22 +4,40 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2", "@nestjs/core": "6.8.2",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"ts-loader": "6.2.0", "@nestjs/schematics": "^6.7.0",
"ts-node": "8.4.1", "@types/node": "^12.7.8",
"tslint": "5.20.0" "@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { AppService } from './app.service';
@Module({ @Module({
providers: [AppService], providers: [AppService],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,9 +1,9 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
import { AppService } from './app.service'; import { AppService } from './app.service';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.createApplicationContext(ApplicationModule); const app = await NestFactory.createApplicationContext(AppModule);
const appService = app.get(AppService); const appService = app.get(AppService);
console.log(appService.getHello()); console.log(appService.getHello());
} }

10819
sample/19-auth-jwt/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -5,13 +5,13 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"format": "prettier --write \"src/**/*.ts\"", "build": "nest build",
"start": "ts-node -r tsconfig-paths/register src/main.ts", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ", "start": "nest start",
"start:debug": "nodemon --config nodemon-debug.json", "start:dev": "nest start --watch",
"prestart:prod": "rimraf dist && npm run build", "start:debug": "nest start --debug --watch",
"start:prod": "node dist/main.js", "start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json", "lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",
@@ -33,22 +33,21 @@
"rxjs": "6.5.3" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/testing": "6.8.2", "@nestjs/cli": "^6.9.1",
"@types/express": "4.17.1", "@nestjs/schematics": "^6.7.0",
"@types/jest": "24.0.18", "@nestjs/testing": "^6.8.0",
"@types/node": "10.14.21", "@types/express": "^4.17.1",
"@types/supertest": "2.0.8", "@types/node": "^12.7.8",
"concurrently": "5.0.0", "@types/supertest": "^2.0.8",
"jest": "23.6.0", "jest": "^24.9.0",
"nodemon": "1.19.3", "prettier": "^1.18.2",
"prettier": "1.18.2", "supertest": "^4.0.2",
"supertest": "4.0.2", "ts-jest": "^24.1.0",
"ts-jest": "24.1.0", "ts-loader": "^6.2.0",
"ts-node": "8.4.1", "ts-node": "^8.4.1",
"tsconfig-paths": "3.9.0", "tsconfig-paths": "^3.9.0",
"tslint": "5.20.0", "tslint": "^5.20.0",
"typescript": "3.6.4", "typescript": "^3.6.3"
"wait-on": "3.3.0"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [

View File

@@ -2,18 +2,18 @@ import { Controller, Get, Request, Post, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { AuthService } from './auth/auth.service'; import { AuthService } from './auth/auth.service';
@Controller('api') @Controller()
export class AppController { export class AppController {
constructor(private readonly authService: AuthService) {} constructor(private readonly authService: AuthService) {}
@UseGuards(AuthGuard('local')) @UseGuards(AuthGuard('local'))
@Post('login') @Post('auth/login')
async login(@Request() req) { async login(@Request() req) {
return this.authService.login(req.user); return this.authService.login(req.user);
} }
@UseGuards(AuthGuard('jwt')) @UseGuards(AuthGuard('jwt'))
@Get('me') @Get('profile')
getProfile(@Request() req) { getProfile(@Request() req) {
return req.user; return req.user;
} }

8987
sample/20-cache/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -17,16 +26,23 @@
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rxjs": "6.5.3"
"typescript": "3.6.4"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "24.0.18", "@nestjs/cli": "^6.9.1",
"@types/node": "10.14.21", "@nestjs/schematics": "^6.7.0",
"jest": "24.9.0", "@nestjs/testing": "^6.8.0",
"supertest": "4.0.2", "@types/express": "^4.17.1",
"ts-jest": "24.1.0", "@types/node": "^12.7.8",
"ts-node": "8.4.1", "@types/supertest": "^2.0.8",
"tslint": "5.20.0" "jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -5,4 +5,4 @@ import { AppController } from './app.controller';
imports: [CacheModule.register()], imports: [CacheModule.register()],
controllers: [AppController], controllers: [AppController],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,9 +1,9 @@
import { ValidationPipe } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe()); app.useGlobalPipes(new ValidationPipe());
await app.listen(3000); await app.listen(3000);
} }

8960
sample/21-serializer/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -15,16 +24,24 @@
"@nestjs/platform-express": "6.8.2", "@nestjs/platform-express": "6.8.2",
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "24.0.18", "@nestjs/cli": "^6.9.1",
"@types/node": "10.14.21", "@nestjs/schematics": "^6.7.0",
"jest": "24.9.0", "@nestjs/testing": "^6.8.0",
"supertest": "4.0.2", "@types/express": "^4.17.1",
"ts-jest": "24.1.0", "@types/node": "^12.7.8",
"ts-node": "8.4.1", "@types/supertest": "^2.0.8",
"tslint": "5.20.0" "jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -4,4 +4,4 @@ import { AppController } from './app.controller';
@Module({ @Module({
controllers: [AppController], controllers: [AppController],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,9 +1,9 @@
import { ValidationPipe } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe()); app.useGlobalPipes(new ValidationPipe());
await app.listen(3000); await app.listen(3000);
} }

12719
sample/22-graphql-prisma/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -19,14 +28,24 @@
"graphql-tools": "4.0.5", "graphql-tools": "4.0.5",
"prisma-binding": "2.3.16", "prisma-binding": "2.3.16",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"nodemon": "1.19.3", "@nestjs/cli": "^6.9.1",
"prettier": "1.18.2", "@nestjs/schematics": "^6.7.0",
"ts-node": "8.4.1", "@nestjs/testing": "^6.8.0",
"tsconfig-paths": "3.9.0", "@types/express": "^4.17.1",
"tslint": "5.20.0" "@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -13,4 +13,4 @@ import { PrismaModule } from './prisma/prisma.module';
PostsModule, PostsModule,
], ],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -21,12 +30,23 @@
"graphql-subscriptions": "1.1.0", "graphql-subscriptions": "1.1.0",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rxjs": "6.5.3",
"type-graphql": "0.17.5", "type-graphql": "0.17.5"
"typescript": "3.6.4"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -3,7 +3,7 @@
# !!! DO NOT MODIFY THIS FILE BY YOURSELF !!! # !!! DO NOT MODIFY THIS FILE BY YOURSELF !!!
# ----------------------------------------------- # -----------------------------------------------
# Date custom scalar type """Date custom scalar type"""
scalar Date scalar Date
type Mutation { type Mutation {

View File

@@ -11,4 +11,4 @@ import { RecipesModule } from './recipes/recipes.module';
}), }),
], ],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,9 +1,9 @@
import { ValidationPipe } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe()); app.useGlobalPipes(new ValidationPipe());
await app.listen(3000); await app.listen(3000);
} }

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"start": "ts-node src/main", "build": "nest build",
"prestart:prod": "npm run build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:prod": "node dist/main.js" "start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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": { "dependencies": {
"@nestjs/common": "6.8.2", "@nestjs/common": "6.8.2",
@@ -17,12 +26,24 @@
"class-transformer": "0.2.3", "class-transformer": "0.2.3",
"class-validator": "0.10.1", "class-validator": "0.10.1",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.5.3", "rimraf": "^3.0.0",
"typescript": "3.6.4" "rxjs": "6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.14.21", "@nestjs/cli": "^6.9.1",
"ts-node": "8.4.1", "@nestjs/schematics": "^6.7.0",
"tslint": "5.20.0" "@nestjs/testing": "^6.8.0",
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/supertest": "^2.0.8",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
} }
} }

View File

@@ -9,4 +9,4 @@ import { ServeStaticModule } from '@nestjs/serve-static';
}), }),
], ],
}) })
export class ApplicationModule {} export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(ApplicationModule); const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api'); app.setGlobalPrefix('api');
await app.listen(3000); await app.listen(3000);
} }

View File

@@ -1,16 +1,16 @@
{ {
"name": "sample-config-service", "name": "nest-typescript-starter",
"version": "0.0.1", "version": "1.0.0",
"description": "", "description": "Nest TypeScript starter repository",
"author": "",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "rimraf dist && tsc -p tsconfig.build.json", "prebuild": "rimraf dist",
"format": "prettier --write \"src/**/*.ts\"", "build": "nest build",
"start": "ts-node -r tsconfig-paths/register src/main.ts", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:dev": "tsc-watch -p tsconfig.build.json --onSuccess \"node dist/main.js\"", "start": "nest start",
"start:debug": "tsc-watch -p tsconfig.build.json --onSuccess \"node --inspect-brk dist/main.js\"", "start:dev": "nest start --watch",
"start:prod": "node dist/main.js", "start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "tslint -p tsconfig.json -c tslint.json", "lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",
@@ -28,21 +28,22 @@
"rxjs": "6.5.2" "rxjs": "6.5.2"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/testing": "6.8.2",
"@types/dotenv": "6.1.1", "@types/dotenv": "6.1.1",
"@types/express": "4.16.1", "@nestjs/cli": "^6.9.1",
"@types/jest": "24.0.11", "@nestjs/schematics": "^6.7.0",
"@types/node": "11.13.22", "@nestjs/testing": "^6.8.0",
"@types/supertest": "2.0.8", "@types/express": "^4.17.1",
"jest": "24.7.1", "@types/node": "^12.7.8",
"prettier": "1.17.0", "@types/supertest": "^2.0.8",
"supertest": "4.0.2", "jest": "^24.9.0",
"ts-jest": "24.1.0", "prettier": "^1.18.2",
"ts-node": "8.4.1", "supertest": "^4.0.2",
"tsc-watch": "4.0.0", "ts-jest": "^24.1.0",
"tsconfig-paths": "3.9.0", "ts-loader": "^6.2.0",
"tslint": "5.16.0", "ts-node": "^8.4.1",
"typescript": "3.6.4" "tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [