Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lite-web-server

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lite-web-server - npm Package Compare versions

Comparing version 1.0.10-beta.1633569780 to 1.0.10

lib/assets/def_pages/404.html

1

CHANGELOG.md

@@ -12,2 +12,3 @@ # Change Log

- options.req405error and options.notfound are changed to options.errordocument._404 and options.errordocument._405
- default 404 and 405 pages are improved.

@@ -14,0 +15,0 @@ ### Fixed

@@ -0,0 +0,0 @@ var { WebServer } = require("./index.js");

2

jsdoc.json

@@ -28,3 +28,3 @@ {

"better-docs": {
"name": "lite-web-server v1.0.10-beta.1633569780",
"name": "lite-web-server v1.0.10",
"title": "lite-web-server Documentation",

@@ -31,0 +31,0 @@ "css": "/style.css",

@@ -13,4 +13,4 @@ const http = require('http');

* @property {boolean} [options.acceptonlyget=true] - Only accepts get request.
* @property {string} [options.errordocument._404=`${__dirname}../assets/def_pages/404.html`] - Html file path to respond on the request methods other than GET.
* @property {string} [options.errordocument._405=`${__dirname}../assets/def_pages/405.html`] - Html file path to respond on not found.
* @property {string} [options.errordocument._404=`${__dirname}/assets/def_pages/404.html`] - Html file path to respond on the request methods other than GET.
* @property {string} [options.errordocument._405=`${__dirname}/assets/def_pages/405.html`] - Html file path to respond on not found.
* @property {boolean} [options.useindexhtml=true] - If it's true, returns ./index.html file when requested directory.

@@ -35,20 +35,24 @@ * @property {string} [options.rootfile=/index.html] - You can specify a file to load as a top page. (Please specify files in the published directory.)

constructor(opts) {
async function run(opts) {
this.opts = opts;
if (opts) {
var error_doc404 = opts.errordocument._404 || `${__dirname}../assets/def_pages/404.html`;
var error_doc405 = opts.errordocument._405 || `${__dirname}../assets/def_pages/405.html`;
this.opts = run(opts);
function run(options) {
if (options) {
if (!options.errordocument) {
options.errordocument = {};
}
var error_doc404 = options.errordocument._404 || `${__dirname}/assets/def_pages/404.html`;
var error_doc405 = options.errordocument._405 || `${__dirname}/assets/def_pages/405.html`;
try {
var _404 = await fs.readFileSync(error_doc404);
var _404 = fs.readFileSync(error_doc404);
} catch (error) {
console.error(new Error(`Invailed 404 error file location "${error_doc404}". Default location will used.`));
opts.errordocument._404 = `${__dirname}../assets/def_pages/404.html`;
options.errordocument._404 = `${__dirname}/assets/def_pages/404.html`;
}
try {
var _405 = await fs.readFileSync(error_doc405);
var _405 = fs.readFileSync(error_doc405);
} catch (error) {
console.error(new Error(`Invailed 405 error file location "${error_doc405}". Default location will used.`));
opts.errordocument._405 = `${__dirname}../assets/def_pages/405.html`;
options.errordocument._405 = `${__dirname}/assets/def_pages/405.html`;
}
}
return options;
}

@@ -76,4 +80,4 @@

errordocument: {
_404: `${__dirname}../assets/def_pages/404.html`,
_405: `${__dirname}../assets/def_pages/405.html`
_404: `${__dirname}/assets/def_pages/404.html`,
_405: `${__dirname}/assets/def_pages/405.html`
}

@@ -105,2 +109,5 @@ }

}
if (!opt.errordocument) {
opt.errordocument = {};
}
var options = {

@@ -115,4 +122,4 @@ directory: dir || "./public",

errordocument: {
_404: options.errordocument._404 || `${__dirname}../assets/def_pages/404.html`,
_405: options.errordocument._405 || `${__dirname}../assets/def_pages/405.html`
_404: opt.errordocument._404 || `${__dirname}/assets/def_pages/404.html`,
_405: opt.errordocument._405 || `${__dirname}/assets/def_pages/405.html`
}

@@ -157,5 +164,5 @@ }

var read_file = await fs.readFileSync(options.errordocument._404).toString();
var file = read_file.replace(/<!--${404URL}-->/g, `${url}`);
var file = read_file.replace(/<!--\${404URL}-->/g, `${url}`);
res.writeHead(404, { "Content-Type": "text/html" });
res.end(options.notfound);
res.end(file);
} catch (error) {

@@ -162,0 +169,0 @@ res.writeHead(500, { "Content-Type": "text/html" });

{
"name": "lite-web-server",
"version": "1.0.10-beta.1633569780",
"version": "1.0.10",
"description": "creates simple web server.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -0,0 +0,0 @@ # lite-web-server

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc