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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main.ts",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js",
"test": "jest --config=jest.json",
"test:watch": "jest --watch --config=jest.json",
"test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage",
"e2e": "jest --config=e2e/jest-e2e.json --forceExit",
"e2e:watch": "jest --watch --config=e2e/jest-e2e.json"
"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": "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": {
"@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2",
"@nestjs/platform-express": "6.8.2",
"@nestjs/testing": "6.8.2",
"@nestjs/websockets": "6.8.2",
"@nestjs/common": "^6.8.0",
"@nestjs/core": "^6.8.0",
"@nestjs/platform-express": "^6.8.0",
"reflect-metadata": "^0.1.13",
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "^6.5.3"
},
"devDependencies": {
"@types/jest": "24.0.18",
"@types/node": "10.14.21",
"jest": "24.9.0",
"supertest": "4.0.2",
"ts-jest": "24.1.0",
"ts-node": "8.4.1",
"tslint": "5.20.0"
"@nestjs/cli": "^6.10.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"
},
"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({
imports: [CatsModule],
})
export class ApplicationModule {}
export class AppModule {}

View File

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

View File

@@ -4,31 +4,51 @@
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main.ts",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2",
"@nestjs/platform-express": "6.8.2",
"@nestjs/platform-socket.io": "6.8.2",
"@nestjs/testing": "6.8.2",
"@nestjs/websockets": "6.8.2",
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3",
"socket.io-redis": "5.2.0",
"typescript": "3.6.4"
"socket.io-redis": "5.2.0"
},
"devDependencies": {
"@types/node": "7.10.7",
"@types/socket.io": "2.1.4",
"@types/socket.io": "2.1.3",
"@types/socket.io-redis": "1.0.25",
"@types/ws": "6.0.3",
"ts-node": "8.4.1",
"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

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

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main.ts",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2",
"@nestjs/microservices": "6.8.2",
"@nestjs/platform-express": "6.8.2",
"@nestjs/testing": "6.8.2",
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@nestjs/cli": "^6.9.1",
"@nestjs/schematics": "^6.7.0",
"@nestjs/testing": "^6.8.0",
"@types/amqplib": "0.5.13",
"@types/node": "10.14.21",
"ts-node": "8.4.1",
"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 { MathModule } from './math/math.module';
@Module({
imports: [MathModule],
})
export class ApplicationModule {}
export class AppModule {}

View File

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

View File

@@ -4,27 +4,48 @@
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main.ts",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@grpc/proto-loader": "0.5.2",
"@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2",
"@nestjs/microservices": "6.8.2",
"@nestjs/testing": "6.8.2",
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"grpc": "1.24.0",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/node": "10.14.21",
"ts-node": "8.4.1",
"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",
"@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({
imports: [HeroModule],
})
export class ApplicationModule {}
export class AppModule {}

View File

@@ -1,5 +1,5 @@
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
import { grpcClientOptions } from './grpc-client.options';
async function bootstrap() {
@@ -7,7 +7,7 @@ async function bootstrap() {
* Hybrid application (HTTP + GRPC)
* Switch to basic microservice with NestFactory.createMicroservice():
*
* const app = await NestFactory.createMicroservice(ApplicationModule, {
* const app = await NestFactory.createMicroservice(AppModule, {
* transport: Transport.GRPC,
* options: {
* package: 'hero',
@@ -17,7 +17,7 @@ async function bootstrap() {
* await app.listenAsync();
*
*/
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
app.connectMicroservice(grpcClientOptions);
await app.startAllMicroservicesAsync();
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -16,13 +25,26 @@
"@nestjs/typeorm": "6.2.0",
"mysql": "2.17.1",
"reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3",
"typeorm": "0.2.19",
"typescript": "3.6.4"
"typeorm": "0.2.19"
},
"devDependencies": {
"@types/node": "7.10.7",
"ts-node": "8.4.1",
"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",
"@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,
],
})
export class ApplicationModule {}
export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
await app.listen(3001);
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -16,13 +25,26 @@
"@nestjs/mongoose": "6.1.2",
"mongoose": "5.7.4",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/mongoose": "5.5.20",
"@types/node": "10.14.21",
"ts-node": "8.4.1",
"tslint": "5.20.0"
"@types/mongoose": "5.5.19",
"@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",
"@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,
],
})
export class ApplicationModule {}
export class AppModule {}

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
await app.listen(3001);
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -15,15 +24,29 @@
"@nestjs/platform-express": "6.8.2",
"mysql2": "1.7.0",
"reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3",
"sequelize": "5.19.5",
"sequelize-typescript": "1.0.0",
"typescript": "3.6.4"
},
"devDependencies": {
"@types/node": "10.14.21",
"@types/sequelize": "4.28.5",
"ts-node": "8.4.1",
"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",
"@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({
imports: [CatsModule],
})
export class ApplicationModule {}
export class AppModule {}

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,31 +1,16 @@
const webpack = require('webpack');
const path = require('path');
const nodeExternals = require('webpack-node-externals');
module.exports = {
module.exports = function(options) {
return {
...options,
entry: ['webpack/hot/poll?100', './src/main.ts'],
target: 'node',
watch: true,
externals: [
nodeExternals({
whitelist: ['webpack/hot/poll?100'],
}),
],
module: {
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',
},
plugins: [...options.plugins, new webpack.HotModuleReplacementPlugin()],
};
};

View File

@@ -1,4 +1,12 @@
{
"presets": ["env", "stage-0"],
"plugins": ["transform-decorators-legacy"]
"presets": ["@babel/preset-env"],
"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-polyfill');
require('@babel/register');
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",
"license": "MIT",
"scripts": {
"build": "babel src -d dist",
"prestart": "npm run build",
"start": "node index.js"
"format": "prettier --write \"**/*.js\"",
"start": "babel-node index.js",
"start:dev": "nodemon",
"test": "jest",
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2",
"@nestjs/microservices": "6.8.2",
"@nestjs/platform-express": "6.8.2",
"@nestjs/testing": "6.8.2",
"@nestjs/websockets": "6.8.2",
"babel-core": "6.26.3",
"babel-polyfill": "6.26.0",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3"
"@nestjs/common": "^6.7.2",
"@nestjs/core": "^6.7.2",
"@nestjs/platform-express": "^6.7.2",
"@nestjs/microservices": "^6.7.2",
"@nestjs/websockets": "^6.7.2",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.5.3"
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-plugin-transform-decorators-legacy": "1.3.5",
"babel-preset-env": "1.7.0",
"babel-preset-stage-0": "6.24.1"
"@babel/core": "^7.6.2",
"@babel/node": "^7.6.2",
"@babel/plugin-proposal-decorators": "^7.6.0",
"@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({
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 { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -16,12 +25,25 @@
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/node": "10.14.21",
"ts-node": "8.4.1",
"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",
"@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({
imports: [CatsModule],
})
export class ApplicationModule {}
export class AppModule {}

View File

@@ -4,11 +4,11 @@ import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
ApplicationModule,
AppModule,
new FastifyAdapter(),
);
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -17,14 +26,25 @@
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3",
"swagger-ui-express": "4.1.2",
"typescript": "3.6.4"
"swagger-ui-express": "4.1.1"
},
"devDependencies": {
"@types/node": "10.14.21",
"supertest": "4.0.2",
"ts-node": "8.4.1",
"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

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

View File

@@ -1,9 +1,9 @@
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
const options = new DocumentBuilder()
.setTitle('Cats example')
@@ -15,6 +15,6 @@ async function bootstrap() {
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
await app.listen(3001);
await app.listen(3000);
}
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -20,12 +29,24 @@
"graphql": "14.5.8",
"graphql-subscriptions": "1.1.0",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/node": "10.14.21",
"ts-node": "8.4.1",
"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

@@ -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 { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -16,13 +25,25 @@
"@nestjs/typeorm": "6.2.0",
"mongodb": "3.3.2",
"reflect-metadata": "0.1.13",
"rimraf": "^3.0.0",
"rxjs": "6.5.3",
"typeorm": "0.2.19",
"typescript": "3.6.4"
"typeorm": "0.2.19"
},
"devDependencies": {
"@types/node": "10.14.21",
"ts-node": "8.4.1",
"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

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

View File

@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
await app.listen(3001);
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -15,13 +24,25 @@
"@nestjs/platform-express": "6.8.2",
"mongoose": "5.7.4",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/mongoose": "5.5.20",
"@types/node": "7.10.7",
"ts-node": "8.4.1",
"tslint": "5.20.0"
"@types/mongoose": "5.5.19",
"@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

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

View File

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

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -16,13 +25,24 @@
"hbs": "4.0.6",
"pug": "2.0.4",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/node": "8.10.54",
"nodemon": "1.19.3",
"ts-node": "8.4.1",
"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],
providers: [],
})
export class ApplicationModule {}
export class AppModule {}

View File

@@ -1,12 +1,10 @@
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(
ApplicationModule,
);
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.useStaticAssets(join(__dirname, '..', 'public'));
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -17,15 +26,27 @@
"@nestjs/websockets": "6.8.2",
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"rimraf": "^3.0.0",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4",
"ws": "7.1.2"
},
"devDependencies": {
"@types/node": "10.14.21",
"@types/ws": "6.0.3",
"ts-node": "8.4.1",
"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

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

View File

@@ -1,9 +1,9 @@
import { NestFactory } from '@nestjs/core';
import { WsAdapter } from '@nestjs/platform-ws';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
app.useWebSocketAdapter(new WsAdapter(app));
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -16,13 +25,27 @@
"handlebars": "4.4.3",
"point-of-view": "3.5.2",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/node": "8.10.54",
"nodemon": "1.19.3",
"ts-node": "8.4.1",
"tslint": "5.20.0"
"@types/socket.io": "2.1.3",
"@types/socket.io-redis": "1.0.25",
"@types/ws": "6.0.3",
"@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],
providers: [],
})
export class ApplicationModule {}
export class AppModule {}

View File

@@ -4,11 +4,11 @@ import {
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { join } from 'path';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
ApplicationModule,
AppModule,
new FastifyAdapter(),
);
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
"@nestjs/core": "6.8.2",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/node": "10.14.21",
"ts-loader": "6.2.0",
"ts-node": "8.4.1",
"tslint": "5.20.0"
"@nestjs/cli": "^6.9.1",
"@nestjs/schematics": "^6.7.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

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

View File

@@ -1,9 +1,9 @@
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
import { AppService } from './app.service';
async function bootstrap() {
const app = await NestFactory.createApplicationContext(ApplicationModule);
const app = await NestFactory.createApplicationContext(AppModule);
const appService = app.get(AppService);
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": "",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"format": "prettier --write \"src/**/*.ts\"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rimraf dist && npm run build",
"start:prod": "node dist/main.js",
"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": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
@@ -33,22 +33,21 @@
"rxjs": "6.5.3"
},
"devDependencies": {
"@nestjs/testing": "6.8.2",
"@types/express": "4.17.1",
"@types/jest": "24.0.18",
"@types/node": "10.14.21",
"@types/supertest": "2.0.8",
"concurrently": "5.0.0",
"jest": "23.6.0",
"nodemon": "1.19.3",
"prettier": "1.18.2",
"supertest": "4.0.2",
"ts-jest": "24.1.0",
"ts-node": "8.4.1",
"tsconfig-paths": "3.9.0",
"tslint": "5.20.0",
"typescript": "3.6.4",
"wait-on": "3.3.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"
},
"jest": {
"moduleFileExtensions": [

View File

@@ -2,18 +2,18 @@ import { Controller, Get, Request, Post, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { AuthService } from './auth/auth.service';
@Controller('api')
@Controller()
export class AppController {
constructor(private readonly authService: AuthService) {}
@UseGuards(AuthGuard('local'))
@Post('login')
@Post('auth/login')
async login(@Request() req) {
return this.authService.login(req.user);
}
@UseGuards(AuthGuard('jwt'))
@Get('me')
@Get('profile')
getProfile(@Request() req) {
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -17,16 +26,23 @@
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/jest": "24.0.18",
"@types/node": "10.14.21",
"jest": "24.9.0",
"supertest": "4.0.2",
"ts-jest": "24.1.0",
"ts-node": "8.4.1",
"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

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

View File

@@ -1,9 +1,9 @@
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -15,16 +24,24 @@
"@nestjs/platform-express": "6.8.2",
"class-transformer": "0.2.3",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/jest": "24.0.18",
"@types/node": "10.14.21",
"jest": "24.9.0",
"supertest": "4.0.2",
"ts-jest": "24.1.0",
"ts-node": "8.4.1",
"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

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

View File

@@ -1,9 +1,9 @@
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
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",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -19,14 +28,24 @@
"graphql-tools": "4.0.5",
"prisma-binding": "2.3.16",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"nodemon": "1.19.3",
"prettier": "1.18.2",
"ts-node": "8.4.1",
"tsconfig-paths": "3.9.0",
"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

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

View File

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

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -21,12 +30,23 @@
"graphql-subscriptions": "1.1.0",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"type-graphql": "0.17.5",
"typescript": "3.6.4"
"type-graphql": "0.17.5"
},
"devDependencies": {
"@types/node": "10.14.21",
"ts-node": "8.4.1",
"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

@@ -3,7 +3,7 @@
# !!! DO NOT MODIFY THIS FILE BY YOURSELF !!!
# -----------------------------------------------
# Date custom scalar type
"""Date custom scalar type"""
scalar Date
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 { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
await app.listen(3000);
}

View File

@@ -4,10 +4,19 @@
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
"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": "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": {
"@nestjs/common": "6.8.2",
@@ -17,12 +26,24 @@
"class-transformer": "0.2.3",
"class-validator": "0.10.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"typescript": "3.6.4"
"rimraf": "^3.0.0",
"rxjs": "6.5.3"
},
"devDependencies": {
"@types/node": "10.14.21",
"ts-node": "8.4.1",
"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

@@ -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 { ApplicationModule } from './app.module';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api');
await app.listen(3000);
}

View File

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