-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (38 loc) · 1.18 KB
/
index.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
43
44
const error = require('./middleware/error')
require('express-async-errors');
const express = require('express');
const config = require('config');
const Joi = require('joi');
const mongoose = require('mongoose')
const app = express();
const genres = require('./routes/genres');
const customers = require('./routes/customers');
const movies = require('./routes/movie');
const rental = require('./routes/rental');
const users = require('./routes/users');
const auth = require('./routes/auth');
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use('/api/genres', genres);
app.use('/api/customers', customers);
app.use('/api/movies', movies)
app.use('/api/rental', rental)
app.use('/api/users', users);
app.use('/api/auth', auth);
app.use(error);
if(!config.get('jwtPrivateKey'))
{
console.log("Fatal Error : jwtPrivateKey is not defined");
process.exit(1);
}
mongoose.connect('mongodb://localhost/musicAPI')
.then(() => {
console.log('Connected to MongoDB');
})
.catch(err => console.error('Could not connect to MongoDB'));
app.get('/', (req, res) => {
res.send('Homepage');
});
app.listen(3000, ()=> {
console.log("App Running on Localhost 3000");
});