Files
MERN-template/server/server.js
T
Ratstail91 7c09ac46da Stripped out a whole bunch of pages, read more
The purpose of this branch is to bring this project in line with the JWT
protcol that the microservice is using. For the time being, it's easier
to get a stripped-down and stable build and replace the lost parts, one-
by-one.
2021-03-08 12:34:41 +11:00

32 lines
761 B
JavaScript

//environment variables
require('dotenv').config();
//libraries
const path = require('path');
//create the server
const express = require('express');
const app = express();
const server = require('http').Server(app);
const bodyParser = require('body-parser');
//config
app.use(bodyParser.json());
//database connection
const database = require('./database');
//send static files
app.use('/', express.static(path.resolve(__dirname, '..', 'public')));
//fallback to the index file
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, '..', 'public' , 'index.html'));
});
//startup
server.listen(process.env.WEB_PORT || 3000, async (err) => {
await database.sync();
console.log(`listening to localhost:${process.env.WEB_PORT || 3000}`);
});