add app.js
This commit is contained in:
parent
78c052bac9
commit
8a01b0ff35
1 changed files with 27 additions and 0 deletions
27
server/app.js
Normal file
27
server/app.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const express = require('express');
|
||||||
|
const cors = require('cors');
|
||||||
|
const path = require('path');
|
||||||
|
// const postsRoutes = require('./routes/posts'); //TODO uncomment as this is built
|
||||||
|
// const projectsRoutes = require('./routes/projects'); //TODO uncomment as this is built
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
// Middleware
|
||||||
|
|
||||||
|
app.use(cors());
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
// API Routes
|
||||||
|
// app.use('/api/posts', postsRoutes); //TODO uncomment as this is built
|
||||||
|
// app.use('/api/projects', projectsRoutes); //TODO uncomment as this is built
|
||||||
|
|
||||||
|
// Serve Static files in production
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
app.use(express.static(path.join(__dirname, '../client/dist')));
|
||||||
|
|
||||||
|
app.get('*', (req, res) => {
|
||||||
|
res.sendFile(path.resolve(__dirname, '../client', 'dist', 'index.html'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = app;
|
Loading…
Reference in a new issue