super-simple-web-server
Advanced tools
Comparing version 1.1.1 to 1.1.2
28
index.js
@@ -27,2 +27,28 @@ const express = require('express'); | ||
//Runs every time a request is recieved | ||
function logger(req, res, next) { | ||
console.log('Request from: ', req.path); //Log the request to the console | ||
next(); //Run the next handler (IMPORTANT, otherwise your page won't be served) | ||
} | ||
/** | ||
* To add middleware set the third arg to a path that resolves to a file exporting a function like so... | ||
* module.exports = (app) => { app.use(someCoolThingHere);} | ||
*/ | ||
const MIDDLEWARE_PATH = path.resolve(process.argv[3] || false); | ||
if (MIDDLEWARE_PATH) { | ||
try { | ||
var initMiddleware = require(MIDDLEWARE_PATH); | ||
initMiddleware(app); | ||
} catch (err) { | ||
console.log('Error initalizing middleware. ', err); | ||
} | ||
} else { | ||
console.log('No middleware found.'); | ||
} | ||
app.use(logger); | ||
app.use(express.static(ROOT_DIR)); | ||
console.log('\n---------------'); | ||
@@ -33,4 +59,2 @@ console.log('Starting static hosts with root: ' + ROOT_DIR); | ||
app.use(express.static(ROOT_DIR)); | ||
app.listen(HTTP_PORT, (err) => { | ||
@@ -37,0 +61,0 @@ if (err) { |
@@ -11,3 +11,3 @@ { | ||
"name": "super-simple-web-server", | ||
"version": "1.1.1" | ||
"version": "1.1.2" | ||
} |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
10711
80
3