backend/api/server.js

44 lines
1.2 KiB
JavaScript

require('dotenv').config();
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const helmet = require('helmet');
const accountsRoute = require('./routes/accountRoute');
const meetingsRoute = require('./routes/meetingRoute');
const participantsRoute = require('./routes/participantRoute');
const possibleDatesRoute = require('./routes/possibleDateRoute');
const availibilityRoute = require('./routes/availibilityRoute');
const authRoute = require('./routes/authRoute');
const server = express();
server.use(cors());
server.use(express.json());
server.use(helmet());
server.use(bodyParser.json());
server.use(
bodyParser.urlencoded({
extended: true,
}),
);
// TODO: Add validation to all requests
server.use(expressValidator());
server.use('/api/accounts', accountsRoute);
server.use('/api/meetings', meetingsRoute);
server.use('/api/participants', participantsRoute);
server.use('/api/possible-dates', possibleDatesRoute);
server.use('/api/availibility', availibilityRoute);
server.use('/api/auth', authRoute);
server.get('/', (req, res) =>
res
.status(200)
.send('<h2>Welcome to Meeting Planner Backend API service.</h2>'),
);
module.exports = server;