lite-web-server
Advanced tools
Comparing version 1.0.6-beta.1633478160 to 1.0.6
# Change Log | ||
### 1.0.6-beta.1633478160 | ||
## 1.0.6 ([npm](https://www.npmjs.com/package/lite-web-server/v/1.0.6) / [Github](https://github.com/chasyumen/lite-web-server/releases/tag/1.0.6)) | ||
@@ -5,0 +5,0 @@ - Fixed [option.acceptonlyget](https://github.com/chasyumen/lite-web-server/issues/7) |
@@ -10,3 +10,3 @@ var { WebServer, GetFileType } = require("./index.js"); //this file loads ./lib/index.js | ||
var filename = "./check.js" | ||
var filename = "./check.html" | ||
var filetype = GetFileType(filename) |
@@ -1,1 +0,7 @@ | ||
module.exports = require('./lib'); | ||
/* | ||
Made by chasyumen | ||
Released under MIT License | ||
*/ | ||
module.exports = require('./lib'); |
@@ -27,3 +27,3 @@ { | ||
"better-docs": { | ||
"name": "lite-web-server v1.0.6-beta.1633478160", | ||
"name": "lite-web-server v1.0.6", | ||
"title": "lite-web-server Documentation", | ||
@@ -30,0 +30,0 @@ "css": "/style.css", |
@@ -0,1 +1,4 @@ | ||
const MimeTypes = require("mime-types") | ||
const path = require('path') | ||
/** | ||
@@ -6,4 +9,3 @@ * Get content type of the file name for http header. | ||
* @returns {string} Filetype | ||
* @example <caption></caption> | ||
* const { GetFileType } = require("lite-web-server") | ||
* @example const { GetFileType } = require("lite-web-server") | ||
* var filetype = GetFileType("main.js") | ||
@@ -13,49 +15,3 @@ */ | ||
function GetFileType(filename) { | ||
var filetype = "text/plain"; | ||
if (filename.endsWith(".html")||filename.endsWith(".htm")) { | ||
filetype = "text/html"; | ||
} else if (filename.endsWith(".css")) { | ||
filetype = "text/css"; | ||
} else if (filename.endsWith(".csv")) { | ||
filetype = "text/csv"; | ||
} else if (filename.endsWith(".js")) { | ||
filetype = "text/javascript"; | ||
} else if (filename.endsWith(".xml")) { | ||
filetype = "text/xml"; | ||
} else if (filename.endsWith(".css")) { | ||
filetype = "text/plain"; | ||
} else if (filename.endsWith(".json")) { | ||
filetype = "application/json"; | ||
} else if (filename.endsWith(".png")) { | ||
filetype = "image/png"; | ||
} else if (filename.endsWith(".jpg")||filename.endsWith(".jpeg")||filename.endsWith(".jfif")) { | ||
filetype = "image/jpeg"; | ||
} else if (filename.endsWith(".gif")) { | ||
filetype = "image/gif"; | ||
} else if (filename.endsWith(".svg")) { | ||
filetype = "image/svg+xml"; | ||
} else if (filename.endsWith(".ico")) { | ||
filetype = "image/x-icon"; | ||
} else if (filename.endsWith(".webp")) { | ||
filetype = "image/webp"; | ||
} else if (filename.endsWith(".tif")) { | ||
filetype = "image/tiff"; | ||
} else if (filename.endsWith(".djvu")) { | ||
filetype = "image/vnd.djvu"; | ||
} else if (filename.endsWith(".mp3")) { | ||
filetype = "audio/mpeg"; | ||
} else if (filename.endsWith(".wav")) { | ||
filetype = "audio/x-wav"; | ||
} else if (filename.endsWith(".flac")) { | ||
filetype = "audio/flac"; | ||
} else if (filename.endsWith(".ogg")) { | ||
filetype = "application/ogg"; | ||
} else if (filename.endsWith(".mp4")) { | ||
filetype = "video/mp4"; | ||
} else if (filename.endsWith(".webm")) { | ||
filetype = "video/webm"; | ||
} else { | ||
filetype = "text/plain"; | ||
} | ||
return filetype; | ||
return MimeTypes.lookup(filename); | ||
} | ||
@@ -62,0 +18,0 @@ |
const GetFileType = require("./GetFileType.js"); | ||
const WebServer = require("./WebServer.js") | ||
const WebServer = require("./WebServer.js"); | ||
@@ -4,0 +4,0 @@ module.exports = { |
@@ -99,3 +99,3 @@ const http = require('http'); | ||
try { | ||
var httpcontent = await GetFileType(filedir.toString()) | ||
var httpcontent = (await GetFileType(filedir.toString())) || "text/plain" | ||
var file = await fs.readFileSync(filedir) | ||
@@ -102,0 +102,0 @@ res.writeHead(200, { "Content-Type": httpcontent }) |
{ | ||
"name": "lite-web-server", | ||
"version": "1.0.6-beta.1633478160", | ||
"version": "1.0.6", | ||
"description": "creates simple web server.", | ||
"dependencies": { | ||
"mime-db": "1.46.0" | ||
}, | ||
"keywords": [ | ||
@@ -6,0 +9,0 @@ "webserver", |
@@ -26,6 +26,6 @@ # lite-web-server | ||
```js | ||
var { WebServer } = require("lite-web-server") | ||
var server = new WebServer() | ||
var { WebServer } = require("lite-web-server"); | ||
var server = new WebServer(); | ||
server.start() | ||
server.start(); | ||
``` | ||
@@ -36,13 +36,12 @@ | ||
```js | ||
var { WebServer } = require("lite-web-server") | ||
var { WebServer } = require("lite-web-server"); | ||
var server = new WebServer({ | ||
dir: "./public_html/" | ||
}) | ||
}); | ||
server.start() | ||
server.start(); | ||
``` | ||
## License | ||
© chasyumen 2021. Released under the MIT license |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
13027
1
196
46
+ Addedmime-db@1.46.0
+ Addedmime-db@1.46.0(transitive)