2020-05-07 13:10:15 +00:00
|
|
|
require('dotenv').config();
|
2020-05-04 10:28:54 +00:00
|
|
|
const express = require('express');
|
2020-05-07 13:10:15 +00:00
|
|
|
const bodyParser = require('body-parser');
|
2020-05-04 10:28:54 +00:00
|
|
|
const cors = require('cors');
|
|
|
|
const helmet = require('helmet');
|
|
|
|
|
2020-05-04 14:02:31 +00:00
|
|
|
const accountsRoute = require('./routes/accountRoute');
|
|
|
|
const meetingsRoute = require('./routes/meetingRoute');
|
2020-05-04 16:47:05 +00:00
|
|
|
const participantsRoute = require('./routes/participantRoute');
|
2020-05-05 09:34:30 +00:00
|
|
|
const possibleDatesRoute = require('./routes/possibleDateRoute');
|
2020-06-02 14:51:42 +00:00
|
|
|
const availabilityRoute = require('./routes/availabilityRoute');
|
2020-05-08 11:12:10 +00:00
|
|
|
const authRoute = require('./routes/authRoute');
|
2020-05-04 10:28:54 +00:00
|
|
|
|
|
|
|
const server = express();
|
|
|
|
|
|
|
|
server.use(cors());
|
2020-05-04 14:02:31 +00:00
|
|
|
server.use(express.json());
|
2020-05-04 10:28:54 +00:00
|
|
|
server.use(helmet());
|
|
|
|
|
2020-05-07 13:10:15 +00:00
|
|
|
server.use(bodyParser.json());
|
|
|
|
server.use(
|
|
|
|
bodyParser.urlencoded({
|
|
|
|
extended: true,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
2020-05-10 22:48:27 +00:00
|
|
|
// TODO: Add validation to all requests
|
|
|
|
server.use(expressValidator());
|
|
|
|
|
2020-05-04 10:28:54 +00:00
|
|
|
server.use('/api/accounts', accountsRoute);
|
2020-05-04 14:02:31 +00:00
|
|
|
server.use('/api/meetings', meetingsRoute);
|
2020-05-04 16:47:05 +00:00
|
|
|
server.use('/api/participants', participantsRoute);
|
2020-05-05 09:34:30 +00:00
|
|
|
server.use('/api/possible-dates', possibleDatesRoute);
|
2020-06-02 14:51:42 +00:00
|
|
|
server.use('/api/availability', availabilityRoute);
|
2020-05-08 11:12:10 +00:00
|
|
|
server.use('/api/auth', authRoute);
|
2020-05-04 10:28:54 +00:00
|
|
|
|
|
|
|
server.get('/', (req, res) =>
|
|
|
|
res
|
|
|
|
.status(200)
|
|
|
|
.send('<h2>Welcome to Meeting Planner Backend API service.</h2>'),
|
|
|
|
);
|
|
|
|
|
|
|
|
module.exports = server;
|