mirror of
https://github.com/dotFionn/iassure-wx.git
synced 2026-03-21 06:22:56 -05:00
Initial commit
This commit is contained in:
26
backend/src/app.ts
Normal file
26
backend/src/app.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import express, { NextFunction, Request, Response } from 'express';
|
||||
import router from './router';
|
||||
|
||||
const { PORT = 3000 } = process.env;
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use('/api', router.router);
|
||||
|
||||
const frontendRoot = '/opt/frontend/dist';
|
||||
app.use(express.static(frontendRoot));
|
||||
app.use((req, res) => res.sendFile(`${frontendRoot}/index.html`));
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
app.use((err, req: Request, res: Response, next: NextFunction) => {
|
||||
console.log('err', err);
|
||||
|
||||
// 500
|
||||
res.status(500).json({ msg: 'an error occurred' });
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(
|
||||
`application is listening on port ${PORT}`,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user