🦁 REST API for the NestJS + Next.js Todo application

Overview

Create new NestJS project

$ npm i -g @nestjs/cli
$ npm i -g yarn

$ nest new api-lesson
# set strict true in tsconfig.json

Install packages

# install prisma
$ yarn add -D prisma
$ yarn add @prisma/client
$ npx prisma init

# add docker-compose.yml file
# start db
$ docker compose up -d
# reset db
$ docker compose rm -s -f -v

# edit DATABASE_URL of .env
# add model definition to schema file

# prisma migrate and type generation
$ npx prisma migrate dev
$ npx prisma studio
$ npx prisma generate

# install packages
$ yarn add @nestjs/config @nestjs/jwt @nestjs/passport 
$ yarn add cookie-parser csurf passport passport-jwt bcrypt class-validator
$ yarn add -D @types/express @types/cookie-parser @types/csurf @types/passport-jwt @types/bcrypt

Create module, controller, service

$ nest g module auth
$ nest g module user
$ nest g module todo
$ nest g module prisma
$ nest g controller auth --no-spec
$ nest g controller user --no-spec
$ nest g controller todo --no-spec
$ nest g service auth --no-spec
$ nest g service user --no-spec
$ nest g service todo --no-spec
$ nest g service prisma --no-spec

Deploy to Heroku

create Procfile

web: npm run start:prod  

create new heroku app

# add config vars  
JWT_SECRET : yours
# Add two Heroku Postgres in add-on
heroku git:remote -a yours
git push heroku main
# edit .env file 
DATABASE_URL=yours
SHADOW_DATABASE_URL=yours
# prisma migrate 
npx prisma migrate deploy
npx prisma studio
# edit .env.local of Next.js
NEXT_PUBLIC_API_URL=https://yours.herokuapp.com 
# deploy to Vercel
# add Vercel domain to cors middleware in NestJS
You might also like...

The nestjs cache module based on cache-manager & decorators 🍃

A progressive Node.js framework for building efficient and scalable server-side applications. zirus-cache zirus-cache for Nest.JS - simple and modern

May 9, 2022

First NestJS project powered by TypeScript (Simple CRUD)

First Nest TS (TypeScript) First NestJS project powered by TypeScript (Simple CRUD) Routes Get All GET http://localhost:3000/products/ Get one GET htt

Feb 22, 2022

NestJS + MikroORM example repository for testing within transactional contexts. Achieve a much faster test suite.

Description Nest NestJS + MikroORM example repository for testing within transactional contexts. Running tests in transactions will speedup your test

Dec 20, 2022

An in-depth implementation of Clean Architecture using NestJS and type-script

Clean Architecture With NestJS Description It's been a while since my last article on how to implement clean architecture on Node.js applications, git

Dec 28, 2022

Nestjs + Typescript + GraphQL

Nestjs Boilerplate: Nestjs + Typescript + GraphQL How to run Install dependencies yarn install Start server for development yarn start:dev Start ser

Jun 27, 2022

external eventbus module for @nestjs/cqrs

A Cqrs External EventBus module for Nest framework (node.js) Now available: Redis-EventBus Installation with npm npm install --save nest-external-even

Dec 23, 2022

:rocket: One command to generate REST APIs for any MySql Database.

:rocket: One command to generate REST APIs for any MySql Database.

Xmysql : One command to generate REST APIs for any MySql database Why this ? Generating REST APIs for a MySql database which does not follow conventio

Dec 30, 2022

Create flexible REST endpoints and controllers from Sequelize models in your Express app

Finale Create flexible REST endpoints and controllers from Sequelize models in your Express or Restify app. This project aims to be a Sequelize 4.x an

Oct 18, 2022

Social-Feeds-APIs - REST APIs to build social media sites.

express4.17.1-in-docker EXPRESS 4.17 SPA IMPORTANT NOTES: 1. Make sure you follow the steps mentioned under "PROJECT START STEPS" and ensure that the

Jan 3, 2022
Comments
  • typo

    typo

    有用なUdemy講座ありがとうございます。

    https://github.com/GomaGoma676/restapi-todo-nestjs/blob/e9a0bf257fa21c05e6a595815fcb09ea2e097275/src/todo/todo.service.ts#L52

    permission

    opened by mendelssohnbach 1
Owner
Udemy course repositories by Kazu T+
This is the source code repos of my Udemy courses, please feel free to utilize them for your learning 🦊
Udemy course repositories by Kazu T+
Simple CRUD application with Nestjs, Prisma and Docker with Postgres

A progressive Node.js framework for building efficient and scalable server-side applications. Description Nest framework TypeScript starter repository

Torr7s 5 Nov 6, 2022
ObjectionJS on steroids for your nestjs application!

Introduction Almost every application nowadays, requires a database to persist data. We have integrated ObjectionJS as our supported ORM. ObjectionJS

Squareboat 7 Dec 15, 2022
This is a boilerplate for Nodejs (Nestjs/typescript) that can be used to make http server application.

Hexagonal architecture Table of Contents Overview Code architecture source code Service build information Regular user Advanced user Deployment Helm K

Moeid Heidari 20 Sep 13, 2022
This is a repository that contains an simple NestJS API about Movies developed at Blue EdTech.

NestJS Movies Technologies and requirements NestJS JavaScript TypeScript Prisma MySQL Project This is a repository that contains an simple NestJS API

Isabella Nunes 2 Sep 28, 2021
Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker

Instructions Starter template for ?? NestJS and Prisma. Checkout NestJS Prisma Schematics to automatically add Prisma support to your Nest application

notiz.dev 1.6k Jan 4, 2023
around nestjs, with prisma and some graphql lib,write less code,create power api

介绍 这是一个 prisma + nestjs + graphql 的集成示例 对于开发者来说,特别是使用 graphql 的时候,只需要写非常少量的代码即可完成数据的各种操作,同时也支持接口透传。 开发&部署 本地开发 npm run start:dev swagger 地址:http://loc

芋头 26 Nov 24, 2022
API developed using NestJS, TypeORM, PgMem and concepts of Clean Architecture

The Powerful NestJS A progressive Node.js framework for building efficient and scalable server-side applications. Clean Architecture The project has b

Matheus Alexandre 20 Jan 2, 2023
API Back-End de NodeJS com NestJS

A progressive Node.js framework for building efficient and scalable server-side applications. Description Nest framework TypeScript starter repository

Glaucio Daniel 5 May 29, 2022
EasyStory REST API made with Nest.js & TypeORM.

Easy Story REST API ?? “EasyStory” is a web platform whose content is published by its users. With "EasyStory" you can publish your own stories or tal

null 2 Sep 13, 2022
Nestjs boilerplate for beginners.

Description Nest framework boilerplate. Installation $ npm install Running the docker for postgres or simply update env with running postgres values $

Harris Gurung 18 Nov 30, 2022