@jnode/server 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/final.js +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jnode/server",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Simple web server package for Node.js.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/final.js CHANGED
@@ -17,7 +17,10 @@ const mimeTypes = require('./mime.json');
17
17
  //process FinalObject
18
18
  async function processFinal(req, res, map, p, e) {
19
19
  //firewall
20
- if (map['+FIREWALL'] && !(await map['+FIREWALL'](req, res, map, p, e))) return;
20
+ if (
21
+ (map['+FIREWALL'] ?? e.default['+FIREWALL']) &&
22
+ !(await (map['+FIREWALL'] ?? e.default['+FIREWALL'])(req, res, map, p, e))
23
+ ) return;
21
24
 
22
25
  //custom function
23
26
  if (map['FUNCTION']) return map['FUNCTION'](req, res, map, p, e);
@@ -89,7 +92,9 @@ async function processFinal(req, res, map, p, e) {
89
92
 
90
93
  //get file size and check file exists
91
94
  try {
92
- fileSize = (await fsPromises.stat(file)).size;
95
+ const stat = await fsPromises.stat(file);
96
+ if (stat.isDirectory()) return '!404'; //return error for directory
97
+ fileSize = stat.size;
93
98
  } catch (err) { return '!404'; } //return error
94
99
 
95
100
  //write head