-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
50 lines (41 loc) · 1.58 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
43
44
45
46
47
48
49
50
// library imports
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const helmet = require('helmet');
require('dotenv').config();
//instantiating server
const server = express();
// middleware instantiation
server.use(express.json());
// security things, google for more info
server.use(helmet());
server.use(cors({
origin: '*'
}));
// route imports
const testRoutes = require('./routes/test-routes');
const userRoutes = require('./routes/user-routes');
const palletRoutes = require('./routes/pallet-routes');
const boxRoutes = require('./routes/box-routes');
const boxLidRoutes = require('./routes/box-lid-routes');
const foamRoutes = require('./routes/foam-routes');
const dividerRoutes = require('./routes/divider-routes');
const orderDetailsRoutes = require('./routes/order-detail-routes');
const kitRoutes = require('./routes/kit-routes');
const quoteRoutes = require('./routes/quote-routes');
// mongoose config
mongoose.connect(process.env.URL, { useUnifiedTopology: true, useNewUrlParser: true, useCreateIndex: true, useFindAndModify: false });
// routes
server.use('/', testRoutes);
server.use('/api/users', userRoutes);
server.use('/api/pallets', palletRoutes);
server.use('/api/boxes', boxRoutes);
server.use('/api/box-lids', boxLidRoutes);
server.use('/api/foam', foamRoutes);
server.use('/api/dividers', dividerRoutes);
server.use('/api/order-details', orderDetailsRoutes);
server.use('/api/kits', kitRoutes);
server.use('/api/quote', quoteRoutes);
// exporting for use in index.js
module.exports = server;