Creating your first NestJS application

Photo by Sereja Ris on Unsplash

What’s NestJS?

When to use NestJS?

Why use NestJS?

Let’s start writing code

Ehm 😅
npm i -g @nestjs/cli
nest new TodoBackend
NestJS bootstrap logs
nest generate module todo
nest generate class todo/entities/Todo --no-spec
npm i @nestjs/typeorm typeorm sqlite3
nest generate service todo/services/todo
nest generate service todo/services/TodoMapper
nest generate controller todo/controllers/todo
@Post()
@UseInterceptors(ClassSerializerInterceptor)
public add(@Body() todo: AddTodoDto): Promise<TodoDto> {
npm i class-transformer class-validator
npm run start
npm run start:debug

Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin. […] For security reasons, browsers restrict cross-origin HTTP requests initiated from scripts. For example, XmlHttpRequest and the Fetch API follow the same-origin policy.

https://developer.mozilla.org/en/docs/Web/HTTP/CORS

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store