• Stars
    star
    424
  • Rank 102,329 (Top 3 %)
  • Language
    TypeScript
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build a REST API with Node.js, Mongoose & TypeScript

Note: This repository includes the postman collection for the finished API

Note 2: Make sure you add .env to your .gitignore before pushing any changes to your repository. You will also want to generate new public & private keys

Generate new keys: https://travistidwell.com/jsencrypt/demo/

Base64 encode the keys: https://www.base64encode.org/

Common issues

Who is this tutorial for?

  • Junior to mid-level developers
  • Anyone interested in building REST APIs with TypeScript

What you will need

  • A running instance of MongoDB
  • Postman
  • An IDE or text editor (VS Code)
  • A web browser
  • A package manager such as NPM or Yarn
  • Node.js installed

What next?

  • Testing the API with Jest
  • Build a React.js user interface
  • Add Prometheus metrics to the API
  • Deploy the API with Caddy & Docker
  • Add Google OAuth

Concepts

  • REST API principals
    • CRUD
    • HTTP methods
  • JWT & refresh tokens
  • Request validation

Technologies

  • Node.js
  • MongoDB with Mongoose
  • TypeScript
  • Express.js & Express.js middleware
  • Zod validation

Video structure

  1. What are we going to build (Postman demo)
  2. Code walk-through
  3. Bootstrap application
    1. Setup express JS
    2. Create routes function
    3. Setup database connection
    4. Setup logger
    5. Validate request middleware
  4. Registration
    1. Create user model
    2. Create user endpoint
    3. Create user session
    4. Deserialize user middleware (refresh tokens)
    5. Get sessions
    6. Delete session
    7. Require user middleware
  5. Product resource
    1. Create product model
    2. Create product
    3. Read product
    4. Update product
    5. Delete product

Data flow

Access & refresh token flow

Deployment

What will we use

  • Docker (image)
  • docker-compose (container)
  • Caddy - Web server
  • DigitalOcean

Note: You will need Docker installed locally if you want to test your Docker configutation

Let's keep in touch

Buy me a Coffee

Sign up to DigitalOcean πŸ’–

More Repositories

1

REST-API-Tutorial

TypeScript
170
star
2

fastify-prisma-rest-api

TypeScript
137
star
3

trpc-tutorial

TypeScript
133
star
4

Testing-Express-REST-API

TypeScript
110
star
5

auth-api-tutorial

TypeScript
91
star
6

youtube-clone

TypeScript
61
star
7

JWT-Access-Refresh-Tokens

TypeScript
58
star
8

t3-chat

TypeScript
57
star
9

Google-OAuth-NodeJS

TypeScript
53
star
10

Realtime-Chat-Application

TypeScript
51
star
11

t3-twitter-clone

TypeScript
40
star
12

TypeGraphQL-Typegoose-GraphQL-Tutorial

TypeScript
33
star
13

beginners-guide-to-next.js

TypeScript
31
star
14

NestJS-GraphQL

TypeScript
27
star
15

caddy-nodejs-docker-tutorial

Dockerfile
25
star
16

go-react-todo

TypeScript
25
star
17

user-api

TypeScript
24
star
18

The-Ultimate-Guide-to-TypeScript-With-Mongoose

TypeScript
21
star
19

REST-API-With-UI

TypeScript
20
star
20

React-Sortable-Table

TypeScript
18
star
21

golang-for-node-devs

Go
15
star
22

with-streaming-with-next.js

TypeScript
15
star
23

NextJS-With-Apollo-Client-Tutorial

TypeScript
15
star
24

FS-URL-shortener-tutorial

JavaScript
14
star
25

password-manager

TypeScript
13
star
26

react-debounce-search

TypeScript
12
star
27

remix-with-apollo

TypeScript
12
star
28

perfect-background-image-tutorial

TypeScript
12
star
29

graphql-twitter-api-clone

TypeScript
11
star
30

event-driven-microservices

TypeScript
11
star
31

nested-comments

TypeScript
10
star
32

pre-signed-put-url

CSS
10
star
33

multi-domain

Go
9
star
34

js-design-patterns

JavaScript
9
star
35

todo-app

TypeScript
9
star
36

React-form-validation

TypeScript
9
star
37

debounce-throttle

TypeScript
8
star
38

t3-generate

Handlebars
8
star
39

chat-tutorial

TypeScript
7
star
40

mongodb-react-pagination

JavaScript
7
star
41

Countdown-Timer

TypeScript
6
star
42

form-generation-library

TypeScript
6
star
43

12-js-tips-and-tricks

JavaScript
5
star
44

TicTacToe

TypeScript
5
star
45

prisma-relationships

TypeScript
5
star
46

just-enough-zod-to-be-productive

TypeScript
5
star
47

buy-me-a-beer

TypeScript
5
star
48

map-reduce-filter

JavaScript
5
star
49

just-enough-fastify-to-be-productive

TypeScript
5
star
50

url-shortener-tutorial

TypeScript
4
star
51

JWT-Library

TypeScript
4
star
52

learn-sql

4
star
53

Remix-IP-Grabber

TypeScript
4
star
54

Sentiment-Analysis-NodeJS

TypeScript
3
star
55

website-scraping-example

HTML
3
star
56

React-with-TypeScript

TypeScript
3
star
57

GoTH

Go
2
star
58

discord-youtube-bot

TypeScript
2
star
59

trpc-chat-pre

TypeScript
2
star
60

typescript-lessons

TypeScript
1
star
61

Punishing-Scammera-with-Puppeteer

TypeScript
1
star
62

Callbacks-Promises-Async-Await

JavaScript
1
star
63

testing

1
star
64

just-enough-git

HTML
1
star
65

wu-tang-clan-name-generator

TypeScript
1
star
66

md

Go
1
star
67

mongoose-change-streams-typescript

TypeScript
1
star
68

build-and-deploy-to-theedge

TypeScript
1
star
69

go-for-ts-developers

Go
1
star