# nestjs-curd **Repository Path**: WEBLXM/nestjs-curd ## Basic Information - **Project Name**: nestjs-curd - **Description**: nestjs curd api - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-24 - **Last Updated**: 2025-05-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 [circleci-url]: https://circleci.com/gh/nestjs/nestA progressive Node.js framework for building efficient and scalable server-side applications.
## 流程命令 借鉴 1.创建`nestjs`项目 ```bash nest new [project-name] ``` 2.集成`prisma` ```bash npm install prisma -D(开发依赖) ``` 3.初始化`prisma` ```bash # 项目根目录生成 prisma/schema.prisma 和 .env 文件 npx prisma init ``` 3.1 如果`prisma`需要接管已存在的数据库 ```bash # 把已有的数据库同步到 schema.prisma 中 npx prisma db pull ``` 3.2 如果`prisma`需要创建新的数据库 ```bash # 就在 schema.prisma 中创建数据库 # 这个命令的主要目的是直接将你的 Prisma schema 文件 (schema.prisma) 的当前状态同步到你的开发数据库中,而不生成或运行任何迁移文件。 npx prisma db push # 这个命令的目的是安全地将你的 Prisma schema 文件 (schema.prisma) 的更改应用到你的开发数据库中,并通过生成和运行迁移文件来跟踪这些更改。 npx prisma migrate dev ``` 3.3 创建`prisma Client` ```bash # 前面同步数据库时(迁移命令),已经执行了 prisma generate。所以现在不需要再次执行了, # 但是一旦Prisma Schema 文件发生了变动,比如修改了模型,就需要再来执行下这个命令,重新生成 Prisma Client。 npx prisma generate ``` 4.prisma连接数据库 ```bash # g('generate') s('service') # nest g s prisma # 在prisma.service.ts中可以配置数据库连接 nest g s [service-name] # g('generate') mo('module') # nest g mo prisma # 使用命令生成模块 会自动把service添加到该模块中 # 配置为全局模块,默认会注入到app.module中 nest g mo [module-name] ``` 5.生成模块 ```bash # g('generate') res('resource') nest g res [module-name] ``` 6.统一返回数据封装 ```bash # nest g s response nest g s [service-name] # nest g mo response nest g mo [module-name] ``` ## RESTFUL API ```txt 创建 POST 201 更新 PATCH 200 删除 DELETE 204 查询 GET 200 查询详情 GET/:id 200 错误码 400 - 请求参数错误 401 - 未授权 403 - 拒绝访问 forbidden 404 - 未找到 500 - 服务器内部错误 504 - 网关超时 503 - 服务器过载 版本控制 /api/v1/user ``` ## Description [Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. ## Project setup ```bash $ pnpm install ``` ## Compile and run the project ```bash # development $ pnpm run start # watch mode $ pnpm run start:dev # production mode $ pnpm run start:prod ``` ## Run tests ```bash # unit tests $ pnpm run test # e2e tests $ pnpm run test:e2e # test coverage $ pnpm run test:cov ``` ## Deployment When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information. If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps: ```bash $ pnpm install -g @nestjs/mau $ mau deploy ``` With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure. ## Resources Check out a few resources that may come in handy when working with NestJS: - Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework. - For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy). - To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/). - Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks. - Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com). - Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com). - To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs). - Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com). ## Support Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). ## Stay in touch - Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec) - Website - [https://nestjs.com](https://nestjs.com/) - Twitter - [@nestframework](https://twitter.com/nestframework) ## License Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).