开源项目 Library-NestJS 使用教程
library-nestjs项目地址:https://gitcode.com/gh_mirrors/li/library-nestjs
1. 项目的目录结构及介绍
library-nestjs/
├── src/
│ ├── app.module.ts
│ ├── main.ts
│ ├── books/
│ │ ├── books.controller.ts
│ │ ├── books.module.ts
│ │ ├── books.service.ts
│ ├── authors/
│ │ ├── authors.controller.ts
│ │ ├── authors.module.ts
│ │ ├── authors.service.ts
├── test/
├── node_modules/
├── package.json
├── tsconfig.json
├── tsconfig.build.json
├── nest-cli.json
目录结构介绍
src/
: 项目的主要源代码目录。app.module.ts
: 应用程序的根模块。main.ts
: 应用程序的入口文件。books/
: 书籍相关的模块、控制器和服务。authors/
: 作者相关的模块、控制器和服务。
test/
: 测试文件目录。node_modules/
: 依赖包目录。package.json
: 项目的依赖和脚本配置文件。tsconfig.json
: TypeScript 编译配置文件。tsconfig.build.json
: 用于构建的 TypeScript 配置文件。nest-cli.json
: NestJS CLI 配置文件。
2. 项目的启动文件介绍
main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
启动文件介绍
main.ts
是项目的入口文件,负责启动 NestJS 应用程序。NestFactory.create(AppModule)
创建应用程序实例。app.listen(3000)
监听端口 3000,启动服务器。
3. 项目的配置文件介绍
package.json
{
"name": "library-nestjs",
"version": "0.0.1",
"description": "",
"author": "",
"license": "MIT",
"scripts": {
"build": "nest build",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^7.0.0",
"@nestjs/core": "^7.0.0",
"@nestjs/platform-express": "^7.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.5.4"
},
"devDependencies": {
"@nestjs/cli": "^7.0.0",
"@nestjs/testing": "^7.0.0",
"@types/jest": "^25.2.3",
"@types/node": "^13.9.1",
"jest": "^25.4.0",
"prettier": "^2.0.4",
"ts-jest": "^25.4.0",
"ts-node": "^8.8.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.7.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
library-nestjs项目地址:https://gitcode.com/gh_mirrors/li/library-nestjs