-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (29 loc) · 1016 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 mongoose = require("mongoose");
const express = require("express");
const app = express();
const config = require("config");
const genres = require("./routes/genres");
const customers = require("./routes/customers");
const movies = require("./routes/movies");
const rentals = require("./routes/rentals");
const users = require("./routes/users");
const auth = require("./routes/auth");
if (!config.get("jwtPrivateKey")) {
console.error("FATAL ERROR : jwtPrivateKey not defined");
process.exit(1);
}
mongoose
.connect("mongodb://localhost/vidly")
.then(() => console.log("Connected to MonogoDB..."))
.catch(() => console.log("Couldn't connect to MonogoDB..."));
app.use(express.json());
app.use("/api/genres", genres);
app.use("/api/customers", customers);
app.use("/api/movies", movies);
app.use("/api/rentals", rentals);
app.use("/api/users", users);
app.use("/api/auth", auth);
const port = process.env.PORT | 3000;
app.listen(port, () => {
console.log(`Listening at http://localhost:${port}`);
});