- Making E2E type-safe APIs is fun and easy
- Gives you a deeper understanding of Next.js
- Going to be very popular (prediction)
- tRPC
- TypeScript
- Prisma (Postgres)
- Zod - Schema validation & type generation
- nodemailer - Sending OTP emails
- Register user
- Login with OTP
- Create a post
- View a post
- List posts
- Enough tRPC to be productive
- Using Next.js as a monorepo
- Some TypeScript
- OPT login flow
- A running instance of a DB (Postgres, Mongo, SQLlite, MYSQL) - Postgres
-
Demo
-
Code walk-through
-
Bootstrap application
- Create app router
- Create router base
- Configure _app.tsx
- Make a request
- Configure prisma
-
Register user
- Create a user model
- Create register user schema
- Configure user router
- Register user resolver
- Register UI
-
User login
- Add login token to prisma
- Login schema
- Configure mailer
- Verify login schema
- Login resolver
- Verify login resolver
- Login UI
-
Create post
- Add post to prisma
- Create post router
- Create post resolver
- Create post UI
-
List posts
- List posts resolver
- List posts UI
-
View single post
- Query post schema
- Query post resolver
- Post UI