开源项目 Library-NestJS 使用教程

开源项目 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

惠焰凡

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值