Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

精读 《Nestjs 文档》 #30

Closed
ascoders opened this issue Aug 13, 2017 · 7 comments
Closed

精读 《Nestjs 文档》 #30

ascoders opened this issue Aug 13, 2017 · 7 comments

Comments

@ascoders
Copy link
Owner

文档地址:https://docs.nestjs.com/

之所以读它,因为它是一个优雅的类库,基于 express,特别支持 typescript,拥有依赖注入、模块拆分,装饰路由等强大特性,对 async、await 处理也符合我的这篇文章思想: Callback Promise Generator Async-Await 和异常处理的演进

再配置上 docker-compose,typeorm,一套精美绝伦的强类型 nodejs framework 就建成了,其开发体验丝毫不亚于基于 java 的框架。

@ascoders
Copy link
Owner Author

由于临近双十一,太忙了,此次暂时不讨论,待会直接上文章。

@Pines-Cheng
Copy link

双十一还早吧。。。

@ascoders ascoders mentioned this issue Sep 2, 2017
65 tasks
@llk2yq
Copy link

llk2yq commented Mar 21, 2018

你好,在知乎和掘金看到了这篇文章,文章里讲到了nestjs里参数验证的部分,其中“对于不同的请求做不同的校样”,请问有没有例子可供参考?
我目前是根据官方文档用了pipe , 但是这样会导致默认全部校验,望指点,感激不尽。

@ascoders
Copy link
Owner Author

是对 “不同实体” 做不同校验,方式是给实体添加装饰器来完成:

@Column({
	comment: '配置 JSON',
	length: 5000,
})
@Validator.IsString({ message: '必须为字符串' })
@Validator.Length(0, 5000, { message: '长度在 0~5000' })
content: string;

@llk2yq
Copy link

llk2yq commented Mar 22, 2018

@ascoders 谢谢,如果方便请移步这里:segmentfault,有详细的描述。

我想请教的是,一个实体,定义的时候会声明校验规则(如你上面所写),在请求的时候可以通过pipe来进行参数验证,可是这个验证默认是 全部验证 ,即所有字段需要符合实体类里定义的规则,可是如你那篇文章里所说一样,有些请求不需要验证所有字段(例如删除和修改),此时具体应该怎样实现?

我根据你所写的 EverythingSubscriber 并不能实现(技术比较渣),请问能否给个demo,或者伪代码,真心感谢~!

@Zyj163
Copy link

Zyj163 commented Jul 19, 2018

上传文件FileInterceptor里MulterOptions的storage要怎么创建啊,有没有像multer中的diskStorage,在哪里导入,有人知道吗

@Suvern
Copy link

Suvern commented Apr 26, 2021

不是很能理解数据库跑在docker里的操作,不方便持久化处理,而且docker-compose会把项目和数据库混在一起。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants