Revert server configuration in its own file

This commit is contained in:
rui hildt 2020-05-04 12:28:54 +02:00
parent 0f11632263
commit dc30471806
2 changed files with 23 additions and 20 deletions

22
api/server.js Normal file
View File

@ -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('<h2>Welcome to Meeting Planner Backend API service.</h2>'),
);
module.exports = server;

View File

@ -1,23 +1,4 @@
const express = require('express'); const server = require('./api/server.js');
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('<h2>Welcome to Meeting Planner Backend API service.</h2>'),
);
const PORT = process.env.PORT || 3001; const PORT = process.env.PORT || 3001;