add empty frontend application, prepare everything
This commit is contained in:
@@ -22,5 +22,10 @@
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"rules": {}
|
||||
"rules": {
|
||||
"eol-last": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
}
|
||||
1358
backend/package-lock.json
generated
1358
backend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,6 @@
|
||||
"author": "Fionn Sperath",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"ejs-mate": "^4.0.0",
|
||||
"express": "^4.18.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
import express, { NextFunction, Request, Response } from 'express';
|
||||
import ejsMate from 'ejs-mate';
|
||||
import router from './router';
|
||||
|
||||
const { PORT = 3000 } = process.env;
|
||||
|
||||
const app = express();
|
||||
|
||||
app.engine('ejs', ejsMate);
|
||||
app.set('views', '/opt/app/views');
|
||||
app.set('view engine', 'ejs');
|
||||
app.use('/api', router.router);
|
||||
|
||||
app.use(router.router);
|
||||
|
||||
app.use('/dist/bootstrap', express.static('/opt/app/public'));
|
||||
|
||||
app.use(express.static('/opt/app/public'));
|
||||
|
||||
app.use((req: Request, res: Response, next: NextFunction) => {
|
||||
// 404
|
||||
return next(new Error('404'));
|
||||
});
|
||||
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) => {
|
||||
// 404
|
||||
res.render('error');
|
||||
console.log('err', err);
|
||||
|
||||
// 500
|
||||
res.status(500).json({ msg: 'an error occurred' });
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import { Router } from 'express';
|
||||
import { Request, Response, Router } from 'express';
|
||||
import fooController from './controllers/foo.controller';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/foo', fooController.getFoo);
|
||||
// aaaaa
|
||||
|
||||
export default { router };
|
||||
router.use((req: Request, res: Response) => {
|
||||
// 404
|
||||
res.status(404).json({ msg: 'the requested resource could not be found' });
|
||||
});
|
||||
|
||||
export default { router };
|
||||
|
||||
@@ -4,4 +4,4 @@ function getFooDetails() {
|
||||
|
||||
export default {
|
||||
getFooDetails,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
"removeComments": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "Node"
|
||||
"moduleResolution": "Node",
|
||||
},
|
||||
"watchOptions": {
|
||||
"watchFile": "fixedpollinginterval"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
<% layout('layout') -%>
|
||||
|
||||
Oops! Something went wrong :(
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>New App 😀</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%- body -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user