- fixed routes

- added head and foot partials
- prepared bootstrap
This commit is contained in:
2023-05-01 18:31:10 +02:00
parent 6f35764a21
commit 5a21e56e80
13 changed files with 62 additions and 21 deletions

View File

@ -6,9 +6,6 @@ import setDemoData from './setDemoData.js';
// Router base is '/dev'
const Router = express.Router();
Router.use("/setDemoData", setDemoData)
export default Router;

View File

@ -48,5 +48,5 @@ export default (req: Request, res: Response) => {
});
});
*/
res.send('Demo data added (not)');
res.status(200).send('Demo data added (not)');
};

View File

@ -0,0 +1,7 @@
import express, { Request, Response } from 'express';
import * as Eta from 'eta';
import { prisma, __path } from '../../index.js';
export default (req: Request, res: Response) => {
res.render(__path + '/src/frontend/demopage.eta.html');
};

View File

@ -3,11 +3,14 @@ import express from 'express';
// Route imports
import skuRoute from './:id.js';
import testRoute from './test.js';
import etaTest from './etaTest.js';
// Router base is '/'
const Router = express.Router();
Router.use('/:id', skuRoute);
Router.use('/etaTest', etaTest);
Router.use('/:id(\\w{8})', skuRoute);
Router.use('/test', testRoute);
export default Router;

View File

@ -2,9 +2,9 @@ import { Express } from 'express';
// Route imports
import frontend_routes from './frontend/index.js';
import static_routes from './frontend/index.js';
import static_routes from './static/index.js';
import api_routes from './api/index.js';
import dev_routes from './frontend/index.js';
import dev_routes from './dev/index.js';
export default (app: Express) => {
app.use('/', frontend_routes);

View File

@ -1,7 +1,7 @@
import express, { Request, Response } from 'express';
import * as fs from 'fs';
import * as Path from 'path';
import { log } from '../../index.js';
import { log, __path } from '../../index.js';
// Router base is '/static'
const Router = express.Router();
@ -11,14 +11,14 @@ const allowedURLs: Array<string> = JSON.parse(fs.readFileSync('allowedStaticPath
const recordedURLs: Array<string> = [];
const debugMode: boolean = JSON.parse(fs.readFileSync('allowedStaticPaths.json', 'utf8')).debugMode;
Router.use('/*', (req: Request, res: Response) => {
Router.use('*', (req: Request, res: Response) => {
if (debugMode) {
res.sendFile(Path.join(__dirname, 'node_modules', req.params[0]));
res.sendFile(Path.join(__path, 'node_modules', req.params[0]));
recordedURLs.push(req.params[0]);
log.web.debug(recordedURLs);
} else {
if (allowedURLs.indexOf(req.params[0]) > -1) {
res.sendFile(Path.join(__dirname, 'node_modules', req.params[0]));
res.sendFile(Path.join(__path, 'node_modules', req.params[0]));
} else {
log.web.warn('Attempt to access restricted asset file ' + req.params[0]);
res.status(403).json({ status: 'error', reason: 'Access to restricted asset file denied' });