feature: update to nest v5
This commit is contained in:
parent
4a63be4f10
commit
f346875387
|
|
@ -389,3 +389,4 @@ Temporary Items
|
||||||
# Local
|
# Local
|
||||||
dokcer-compose.yml
|
dokcer-compose.yml
|
||||||
.env
|
.env
|
||||||
|
dist
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,10 @@ $ npm run start
|
||||||
# watch mode
|
# watch mode
|
||||||
$ npm run start:dev
|
$ npm run start:dev
|
||||||
|
|
||||||
|
# incremental rebuild (webpack)
|
||||||
|
$ npm run webpack
|
||||||
|
$ npm run start:hmr
|
||||||
|
|
||||||
# production mode
|
# production mode
|
||||||
npm run start:prod
|
npm run start:prod
|
||||||
```
|
```
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
|
|
@ -9,9 +9,11 @@
|
||||||
"start:dev": "nodemon",
|
"start:dev": "nodemon",
|
||||||
"prestart:prod": "rm -rf dist && tsc",
|
"prestart:prod": "rm -rf dist && tsc",
|
||||||
"start:prod": "node dist/main.js",
|
"start:prod": "node dist/main.js",
|
||||||
|
"start:hmr": "node dist/server",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:cov": "jest --coverage",
|
"test:cov": "jest --coverage",
|
||||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||||
|
"webpack": "webpack --config webpack.config.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs/common": "^4.5.9",
|
"@nestjs/common": "^4.5.9",
|
||||||
|
|
@ -19,6 +21,7 @@
|
||||||
"@nestjs/microservices": "^4.5.8",
|
"@nestjs/microservices": "^4.5.8",
|
||||||
"@nestjs/testing": "^4.5.5",
|
"@nestjs/testing": "^4.5.5",
|
||||||
"@nestjs/websockets": "^4.5.8",
|
"@nestjs/websockets": "^4.5.8",
|
||||||
|
"deprecate": "^1.0.0",
|
||||||
"reflect-metadata": "^0.1.12",
|
"reflect-metadata": "^0.1.12",
|
||||||
"rxjs": "^5.5.6",
|
"rxjs": "^5.5.6",
|
||||||
"typescript": "^2.6.2"
|
"typescript": "^2.6.2"
|
||||||
|
|
@ -33,12 +36,20 @@
|
||||||
"prettier": "^1.11.1",
|
"prettier": "^1.11.1",
|
||||||
"supertest": "^3.0.0",
|
"supertest": "^3.0.0",
|
||||||
"ts-jest": "^21.2.4",
|
"ts-jest": "^21.2.4",
|
||||||
|
"ts-loader": "^4.1.0",
|
||||||
"ts-node": "^4.1.0",
|
"ts-node": "^4.1.0",
|
||||||
"tsconfig-paths": "^3.1.1",
|
"tsconfig-paths": "^3.1.1",
|
||||||
"tslint": "5.3.2"
|
"tslint": "5.3.2",
|
||||||
|
"webpack": "^4.2.0",
|
||||||
|
"webpack-cli": "^2.0.13",
|
||||||
|
"webpack-node-externals": "^1.6.0"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"moduleFileExtensions": ["js", "json", "ts"],
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"testRegex": ".spec.ts$",
|
"testRegex": ".spec.ts$",
|
||||||
"transform": {
|
"transform": {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
import { Get, Controller } from '@nestjs/common';
|
import { Get, Controller } from '@nestjs/common';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
export class AppController {
|
export class AppController {
|
||||||
|
constructor(private readonly appService: AppService) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
root(): string {
|
root(): string {
|
||||||
return 'Hello World!';
|
return this.appService.root();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [],
|
imports: [],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
components: [],
|
providers: [AppService],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AppService {
|
||||||
|
root(): string {
|
||||||
|
return 'Hello World!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
|
declare const module: any;
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const app = await NestFactory.create(AppModule);
|
||||||
|
await app.listen(3000);
|
||||||
|
|
||||||
|
if (module.hot) {
|
||||||
|
module.hot.accept();
|
||||||
|
module.hot.dispose(() => app.close());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bootstrap();
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const path = require('path');
|
||||||
|
const nodeExternals = require('webpack-node-externals');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: ['webpack/hot/poll?1000', './src/main.hmr.ts'],
|
||||||
|
watch: true,
|
||||||
|
target: 'node',
|
||||||
|
externals: [
|
||||||
|
nodeExternals({
|
||||||
|
whitelist: ['webpack/hot/poll?1000'],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
use: 'ts-loader',
|
||||||
|
exclude: /node_modules/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
mode: "development",
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.tsx', '.ts', '.js'],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
path: path.join(__dirname, 'dist'),
|
||||||
|
filename: 'server.js',
|
||||||
|
},
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue