how to create a secure rest api with node js and express

Solutions on MaxInterview for how to create a secure rest api with node js and express by the best coders in the world

showing results for - "how to create a secure rest api with node js and express"
Elizabeth
15 Aug 2017
1/*
2    This code comes from Vincent Lab
3    And it has a video version linked here: https://www.youtube.com/watch?v=Tw5LupcpKS4
4*/
5
6// Import dependencie
7const express = require("express");
8
9// Setup the express server
10const app = express();
11const port = 3000;
12
13// Import middlewares into express
14app.use(express.json({ limit: "100mb" }));
15
16// Import routes
17const authRouter = require("./routes/auth");
18const messagesRouter = require("./routes/messages");
19
20// Setup all the routes
21app.use("/api/messages", messagesRouter);
22app.use("/api/auth", authRouter);
23
24// Start the server
25app.listen(port, () => {
26  console.log(`Listening on port ${port}...`);
27});