|
6 天之前 | |
---|---|---|
.. | ||
src | 6 天之前 | |
test | 2 周之前 | |
uploads | 6 天之前 | |
.gitignore | 2 周之前 | |
.prettierrc | 2 周之前 | |
ESLINT_FIXES.md | 6 天之前 | |
FILE_UPLOAD_README.md | 6 天之前 | |
README.md | 6 天之前 | |
eslint.config.mjs | 2 周之前 | |
nest-cli.json | 2 周之前 | |
package.json | 6 天之前 | |
pnpm-lock.yaml | 6 天之前 | |
test-file-upload.md | 6 天之前 | |
tsconfig.build.json | 2 周之前 | |
tsconfig.json | 2 周之前 |
一个基于NestJS框架的图书管理系统后端API。
在项目根目录创建 .env
文件,添加以下配置:
# 服务器配置
SERVER_URL=http://localhost:3000
FILE_PATH=./uploads
PORT=3000
# 数据库配置
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=123456
DB_DATABASE=books
# 其他配置
NODE_ENV=development
SERVER_URL
: 服务器地址,用于生成文件访问URL(默认:http://localhost:3000)FILE_PATH
: 文件存储路径(默认:./uploads)PORT
: 服务器端口(默认:3000)DB_HOST
: 数据库主机地址DB_PORT
: 数据库端口DB_USERNAME
: 数据库用户名DB_PASSWORD
: 数据库密码DB_DATABASE
: 数据库名称curl -X POST http://localhost:3000/file/upload -F "file=@test.jpg"
curl -X GET http://localhost:3000/file/download/[fileId]
或在浏览器中访问:http://localhost:3000/file/download/[fileId]
A progressive Node.js framework for building efficient and scalable server-side applications.
<p align="center">
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
Nest framework TypeScript starter repository.
$ pnpm install
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
# unit tests
$ pnpm run test
# e2e tests
$ pnpm run test:e2e
# test coverage
$ pnpm run test:cov
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 for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ 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.
Check out a few resources that may come in handy when working with NestJS:
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.
Nest is MIT licensed.
https://www.cnblogs.com/bluecobra/archive/2012/01/11/2318922.html