- fixed routes
- added head and foot partials - prepared bootstrap
This commit is contained in:
		| @@ -1,12 +1,13 @@ | ||||
| { | ||||
| 	"allowedStaticFiles": [ | ||||
| 		"bootstrap-icons/font/bootstrap-icons.css", | ||||
| 		"bootstrap/dist/css/bootstrap.min.css", | ||||
| 		"bootstrap/dist/js/bootstrap.bundle.min.js", | ||||
| 		"jquery/dist/jquery.min.js", | ||||
| 		"darkreader/darkreader.js", | ||||
| 		"bootstrap-icons/font/fonts/bootstrap-icons.woff2", | ||||
| 		"bootstrap/dist/css/bootstrap.min.css.map" | ||||
| 		"/bootstrap-icons/font/bootstrap-icons.css", | ||||
| 		"/bootstrap/dist/css/bootstrap.min.css", | ||||
| 		"/bootstrap/dist/js/bootstrap.bundle.min.js", | ||||
| 		"/jquery/dist/jquery.min.js", | ||||
| 		"/darkreader/darkreader.js", | ||||
| 		"/bootstrap-icons/font/fonts/bootstrap-icons.woff2", | ||||
| 		"/bootstrap/dist/css/bootstrap.min.css.map", | ||||
| 		"/@popperjs/core/dist/cjs/popper.js" | ||||
| 	], | ||||
| 	"debugMode": false | ||||
| 	"debugMode": true | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -9,6 +9,7 @@ | ||||
|       "version": "1.0.0", | ||||
|       "license": "GPL-3.0", | ||||
|       "dependencies": { | ||||
|         "@popperjs/core": "^2.11.7", | ||||
|         "@prisma/client": "^4.13.0", | ||||
|         "bootstrap": "^5.3.0-alpha3", | ||||
|         "bootstrap-icons": "^1.10.5", | ||||
| @@ -202,7 +203,6 @@ | ||||
|       "version": "2.11.7", | ||||
|       "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.7.tgz", | ||||
|       "integrity": "sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw==", | ||||
|       "peer": true, | ||||
|       "funding": { | ||||
|         "type": "opencollective", | ||||
|         "url": "https://opencollective.com/popperjs" | ||||
|   | ||||
| @@ -17,6 +17,7 @@ | ||||
|   "author": "[Project-Name-Here]", | ||||
|   "license": "GPL-3.0", | ||||
|   "dependencies": { | ||||
|     "@popperjs/core": "^2.11.7", | ||||
|     "@prisma/client": "^4.13.0", | ||||
|     "bootstrap": "^5.3.0-alpha3", | ||||
|     "bootstrap-icons": "^1.10.5", | ||||
|   | ||||
							
								
								
									
										8
									
								
								src/frontend/demopage.eta.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/frontend/demopage.eta.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <%~ E.includeFile("head.eta.html") %> | ||||
|  | ||||
| <div class="alert alert-primary" role="alert"> | ||||
| 	A simple primary alert—check it out! | ||||
|       </div> | ||||
|        | ||||
|  | ||||
| <%~ E.includeFile("foot.eta.html") %> | ||||
							
								
								
									
										4
									
								
								src/frontend/foot.eta.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								src/frontend/foot.eta.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| <script src="/static/bootstrap/dist/js/bootstrap.bundle.min.js"></script> | ||||
| <script src="/static/@popperjs/core/dist/cjs/popper.js"></script> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										20
									
								
								src/frontend/head.eta.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/frontend/head.eta.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| <!DOCTYPE html> | ||||
|  | ||||
| <html lang="en"> | ||||
| 	<head> | ||||
| 		<meta charset="utf-8" /> | ||||
| 		<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||||
|  | ||||
| 		<title>AssetFlow - Info about item</title> | ||||
| 		<meta name="description" content="A simple HTML5 Template for new projects." /> | ||||
| 		<meta name="author" content="[Project-Name-Here]" /> | ||||
|  | ||||
| 		<link rel="icon" href="/favicon.ico" /> | ||||
| 		<link rel="icon" href="/favicon.svg" type="image/svg+xml" /> | ||||
|  | ||||
| 		<script src="/static/jquery/dist/jquery.min.js"></script> | ||||
| 		<link href="/static/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> | ||||
| 		<link href="/static/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet"> | ||||
| 		 | ||||
| 	</head> | ||||
| 	<body> | ||||
| @@ -41,7 +41,7 @@ export const prisma = new PrismaClient({ | ||||
| }); | ||||
|  | ||||
| export const app = express(); | ||||
|  | ||||
| app.engine("html", require("eta").renderFile) | ||||
| routes(app); | ||||
|  | ||||
| app.listen(config.global.http_port, config.global.http_listen_address, () => { | ||||
|   | ||||
| @@ -6,9 +6,6 @@ import setDemoData from './setDemoData.js'; | ||||
| // Router base is '/dev' | ||||
| const Router = express.Router(); | ||||
|  | ||||
|  | ||||
|  | ||||
| Router.use("/setDemoData", setDemoData) | ||||
|  | ||||
|  | ||||
| export default Router; | ||||
|   | ||||
| @@ -48,5 +48,5 @@ export default (req: Request, res: Response) => { | ||||
| 		}); | ||||
| 	}); | ||||
|  */ | ||||
| 	res.send('Demo data added (not)'); | ||||
| 	res.status(200).send('Demo data added (not)'); | ||||
| }; | ||||
|   | ||||
							
								
								
									
										7
									
								
								src/routes/frontend/etaTest.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/routes/frontend/etaTest.ts
									
									
									
									
									
										Normal 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'); | ||||
| }; | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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' }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user