-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 779 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const express = require("express");
const knex = require("knex");
const dotenv = require("dotenv");
const pg = require("pg");
const helmet = require("helmet");
const morgan = require("morgan");
const userRouter = require("./routers/userRouter");
require("dotenv").config();
const app = express();
const port = process.env.PORT || 5500;
// Middleware
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(helmet());
app.use(morgan("common"));
// Routes
app.get("/", (req, res) => {
res.send("Hello, world!");
});
// Points to the userRouter and adds the /users prefix to all routes in the userRouter.
app.use("/users", userRouter);
// Listen
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
module.exports = app;