forked from NathCoursey/myBooksy-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (32 loc) · 1.07 KB
/
server.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
34
35
36
37
38
39
40
41
42
///////////////////////////////
// DEPENDENCIES
////////////////////////////////
const express = require("express");
const app = express();
const cors = require("cors")
const morgan = require("morgan")
// initialize .env variables
require("dotenv").config();
require('./config/db.connection');
app.use(cors());
app.use(morgan("dev"));
// pull PORT from .env, give default value of 4000 and establish DB Connection
const { PORT, MONGODB_URI } = process.env;
const booksController = require('./controllers/books-controller')
const reviewsController = require('./controllers/reviews-controllers')
const userController = require('./controllers/auth-controller')
app.use(express.json())
// import express
///////////////////////////////
// ROUTES
////////////////////////////////
app.use('/books', booksController)
app.use('/reviews', reviewsController)
app.use('/auth', userController)
app.get("/", (req, res) => {
res.send("myBooksy API");
});
///////////////////////////////
// LISTENER
////////////////////////////////
app.listen(PORT, () => console.log(`listening on PORT ${PORT}`));