-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (21 loc) · 725 Bytes
/
index.js
File metadata and controls
21 lines (21 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import express, {json} from "express";
import cors from "cors"
import './server/db/mongoose.js'
import { indexBank } from "./server/routes/routes.js";
import * as url from 'url';
import path from 'path';
const __dirname = url.fileURLToPath(new URL('./', import.meta.url));
const app = express();
const PORT = process.env.PORT || 8000;
app.use(json());
app.use(cors());
const publicPath = path.join(__dirname, 'server','build');
app.use(express.static(publicPath));
app.use("/api", indexBank);
app.get('*', (req, res) => {
console.log(__dirname);
res.sendFile(path.resolve(__dirname, 'server','build','index.html'));
});
app.listen(PORT, () => {
console.log(` app listening on port ${PORT}`);
});