Hey there! I'm Buqiyuan
A front-end developer, open source is my hobby!
- blog: https://buqiyuan.github.io
- email: [email protected]
NestJS CRUD for RESTful API 使用 NestJS + Mysql + Typeorm + Redis + JWT + Swagger 企业中后台管理系统项目RBAC权限管理(细粒度到按钮)、实现单点登录等...
Home Page: https://vue3-antdv-admin.pages.dev
License: MIT License
A front-end developer, open source is my hobby!
有相关的交流群吗?
async refreshToken(accessToken: AccessTokenEntity) {
const { user, refreshToken } = accessToken
if (refreshToken) {
const now = dayjs()
// 判断refreshToken是否过期
if (now.isAfter(refreshToken.expired_at))
return null
const roleIds = await this.roleService.getRoleIdsByUser(user.id)
const roleValues = await this.roleService.getRoleValues(roleIds)
// 如果没过期则生成新的access_token和refresh_token
const token = await this.generateAccessToken(user.id, roleValues)
await accessToken.remove()
return token
}
return null
}
refreshToken没有相关接口,refreshToken校验也只用了过期时间匹配,
举例:字典新增时会提示【名称不能重复】,但是新增后再编辑时没有了此判断,编辑保存时导致与现有数据名称重复;项目中多个地方都存在此类问题;
[Nest] 36164 - 2024/02/22 12:39:59 WARN [AllExceptionsFilter] 错误信息:(200) 验证码发送失败 Path: /api/auth/email/send unhandledRejection: Error: ENOENT: no such file or directory, open 'E:\dev\York\pc-service\dist\assets\templates\verification-code-zh.hbs'
请问如何解决。谢谢
helmet和express rate limit都是express. js的库,而大佬你的这个项目底层是基于fastify的,请问fastify有类似的库吗?或者整个项目底层切换成express便捷吗?感谢
表格搜索中的时间范围搜索未生效 如登录日志的时间查询
1.进入登录日志查询 选择一个时间范围,查询条件不生效
https://buqiyuan.github.io/vue3-antdv-admin/#/system/monitor/login-log
在api接口文档中 传入的time为一个字符串数组,值为time,
表格中发起请求的地址为 https://nest-api.buqiyuan.site/api/system/log/login/list?time[]=Tue,+07+May+2024+07:32:58+GMT&time[]=Mon,+13+May+2024+07:32:58+GMT&page=1&pageSize=10
nestjs 解析查询参数后 值为’time[]‘, 关闭查询参数过滤后 通过dto['time[]'] 能获取到该数组。
通过 docker build -t web-api .
不能正常构建镜像。
原配置文件没做变更
cd $workspace
docker build -t web-api
如何优雅地更新生产环境数据库
我的部署方式是用 docker compose 服务器上只有docker compose
我本地的项目执行打包 并将镜像包传到镜像仓库 然后再服务器上拉取部署
目前业务中修改了一些表的字段 想要同步到生产环境
看到了迁移的命令和方法但是有点疑惑
作者本地的mailService能用吗?我调用send方法一直报错参数看来都是正确的
this.mailerService.sendMail({
to,
subject,
text: content,
})
报错信息:[Nest] 9396 - 2024/05/14 15:23:15 ERROR [Catch] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
在使用pnpm 安装之后 由于幽灵依赖,导致无法正常运行
需要pnpm 手动安装
pnpm add [email protected] dotenv cron-parser [email protected]
特此记录
src/modules/netdisk/overview/overview.service.ts
blob_io的参数是$bucket,但是space和count是bucket,导致如果有多个bucket的时候space和count统计出来是所有bucket的数据
getStatisticUrl(type: string, queryParams = {}) {
const bucketKey = type === 'blob_io' ? '$bucket' : 'bucket'
const defaultParams = {
[bucketKey]: this.qiniuConfig.bucket,
g: 'day',
}
const searchParams = new URLSearchParams({ ...defaultParams, ...queryParams })
return decodeURIComponent(`${OSS_API}/v6/${type}?${searchParams}`)
}
Axios应该整个原生响应都可以配置好点吧,现在要对原生res做处理要改的地方有点多(比如我要获取流)。
定时任务按【时间间隔】设置任务,修改创建成功后执行正常;此时编辑时间间隔再保存;定时任务执行一次后就会自动关闭
多个使用basecurd工厂时,会导致重复命名为dto然后数据模型丢失,只保留一个
将工厂中的@ApiBody({ type: Dto })改为dto可解决
@ApiTags('goods')
@ApiSecurityAuth()
export class GoodController extends BaseCrudFactory({ entity: GoodEntity, dto: GoodDto }) {
constructor(private readonly service: GoodService) {
super(service)
}
}
@ApiTags('orders')
@ApiSecurityAuth()
export class OrderController extends BaseCrudFactory({ entity: OrderEntity, dto: OrderDto }) {
constructor(
private service: OrderService,
) {
super(service)
}
}
CacheSevice要怎么修改 才能用redis作为缓存?
作为一个前端的,有点不太懂后端的东西,能出一期视频教程吗
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] SharedModule dependencies initialized +1ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] MailerModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] PassportModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] SystemModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] HttpModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] ThrottlerModule dependencies initialized +1ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] DiscoveryModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] RouterModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 15984 - 2024/02/08 11:25:38 ERROR [ExceptionHandler] JwtStrategy requires a secret or key
TypeError: JwtStrategy requires a secret or key
at new JwtStrategy (E:\dev\YorkPorn\nest-admin-main2\node_modules.pnpm\[email protected]\node_modules\passport-jwt\lib\strategy.js:45:15)
at new MixinStrategy (E:\dev\YorkPorn\nest-admin-main2\node_modules.pnpm@nestjs+passport@10.0.3_@nestjs[email protected][email protected]\node_modules@nestjs\passport\dist\passport\passport.strategy.js:32:13)
at new JwtStrategy (E:\dev\YorkPorn\nest-admin-main2\dist\modules\auth\strategies\jwt.strategy.js:24:9)
at Injector.instantiateClass (E:\dev\YorkPorn\nest-admin-main2\node_modules.pnpm@nestjs+core@10.3.2_@nestjs+common@10.3.2_@nestjs[email protected][email protected][email protected]\node_modules@nestjs\core\injector\injector.js:365:19)
at callback (E:\dev\YorkPorn\nest-admin-main2\node_modules.pnpm@nestjs+core@10.3.2_@nestjs+common@10.3.2_@nestjs[email protected][email protected][email protected]\node_modules@nestjs\core\injector\injector.js:65:45)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Injector.resolveConstructorParams (E:\dev\YorkPorn\nest-admin-main2\node_modules.pnpm@nestjs+core@10.3.2_@nestjs+common@10.3.2_@nestjs[email protected][email protected][email protected]\node_modules@nestjs\core\injector\injector.js:144:24)
at async Injector.loadInstance (E:\dev\YorkPorn\nest-admin-main2\node_modules.pnpm@nestjs+core@10.3.2_@nestjs+common@10.3.2_@nestjs[email protected][email protected][email protected]\node_modules@nestjs\core\injector\injector.js:70:13)
at async Injector.loadProvider (E:\dev\YorkPorn\nest-admin-main2\node_modules.pnpm@nestjs+core@10.3.2_@nestjs+common@10.3.2_@nestjs[email protected][email protected][email protected]\node_modules@nestjs\core\injector\injector.js:97:9)
at async E:\dev\YorkPorn\nest-admin-main2\node_modules.pnpm@nestjs+core@10.3.2_@nestjs+common@10.3.2_@nestjs[email protected][email protected][email protected]\node_modules@nestjs\core\injector\instance-loader.js:56:13
大佬,能不能写一个例子来接收form-data表单的数据,就是那种包含文件流跟表单数据的
包含file类型的文件跟jsonstring类型的表单数据,折腾了好几天搞不定.
以前使用的nest+express很容易实现,但是现在项目中使用nest+ Fastify有点搞不定
您好 请教下,这个可以自动生成增删改查吗
我新建的事件模块或者其他所有菜单,我使用的超管角色,为啥模块都是接口无权限啊,我想在无@authorize()时接口也可以正常使用
比如:
@Post('list')
async info_list(@Body() dto: InfoEventManagementDto): Promise<responResult> {
return await this.EventManagementService.info_list(dto);
}
这样接口也能正常不报无权限问题
对部署这一款比较迷茫,采用docker+pm2 是不是就不需要部署多个docker容器了(针对多核CPU的情况)
最近正好在学nestjs,大佬可以建一个微信群吗,方面大家交流
我准备写一个api文档,但这个swagger 本身的ui不太好用
请问如何部署到服务器
如题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.