diff --git a/api/server.js b/api/server.js new file mode 100644 index 0000000..d44db72 --- /dev/null +++ b/api/server.js @@ -0,0 +1,22 @@ +const express = require('express'); +const cors = require('cors'); +const helmet = require('helmet'); +require('dotenv').config(); + +const accountsRoute = require('../api/routes/accountRoute'); + +const server = express(); + +server.use(express.json()); +server.use(cors()); +server.use(helmet()); + +server.use('/api/accounts', accountsRoute); + +server.get('/', (req, res) => + res + .status(200) + .send('

Welcome to Meeting Planner Backend API service.

'), +); + +module.exports = server; diff --git a/index.js b/index.js index 1065256..c2f8195 100644 --- a/index.js +++ b/index.js @@ -1,23 +1,4 @@ -const express = require('express'); -const cors = require('cors'); -const helmet = require('helmet'); -require('dotenv').config(); - -const accountsRoute = require('./api/routes/accountRoute'); - -const server = express(); - -server.use(express.json()); -server.use(cors()); -server.use(helmet()); - -server.use('/api/accounts', accountsRoute); - -server.get('/', (req, res) => - res - .status(200) - .send('

Welcome to Meeting Planner Backend API service.

'), -); +const server = require('./api/server.js'); const PORT = process.env.PORT || 3001;