-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (26 loc) · 827 Bytes
/
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
const Express = require('express');
const Mongoose = require('mongoose');
const BodyParser = require('body-parser');
const DotEnv = require('dotenv').config();
const Multer = require('multer');
const Cors = require('cors');
const app = Express();
const PORT = process.env.PORT | 3000;
Mongoose.connect(
`mongodb+srv://${process.env.DB_USER}:${
process.env.DB_PASS
}@pet-shop-hmtxn.gcp.mongodb.net/test?retryWrites=true`,
);
app.use(Cors());
app.use(BodyParser.json());
const {AuthRoute, AuthorRoute, BookRoute} = require('./src/route');
app
.use('/api/auth/', AuthRoute)
.use('/api/author/', AuthorRoute)
.use('/api/book/', BookRoute);
app.use(function(req, res) {
res.status(404).json({message: 'api route not found'});
});
app.listen(PORT, () => {
console.log(`Your app running on port ${PORT}`);
});