add app.js

This commit is contained in:
Kyle Belanger 2025-02-28 11:15:00 -05:00
parent 78c052bac9
commit 8a01b0ff35

27
server/app.js Normal file
View 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;