remove node, add gitignore n readme

This commit is contained in:
Djkato 2023-02-18 19:06:26 +01:00
parent e89eb44e99
commit c7743bbcd0
15 changed files with 0 additions and 458 deletions

12
node_modules/.bin/tiny-server generated vendored
View file

@ -1,12 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../tiny-server/bin/index" "$@"
else
exec node "$basedir/../tiny-server/bin/index" "$@"
fi

17
node_modules/.bin/tiny-server.cmd generated vendored
View file

@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\tiny-server\bin\index" %*

28
node_modules/.bin/tiny-server.ps1 generated vendored
View file

@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../tiny-server/bin/index" $args
} else {
& "$basedir/node$exe" "$basedir/../tiny-server/bin/index" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../tiny-server/bin/index" $args
} else {
& "node$exe" "$basedir/../tiny-server/bin/index" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
node_modules/.package-lock.json generated vendored
View file

@ -1,16 +0,0 @@
{
"name": "performance-bug-unmuted-window",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"node_modules/tiny-server": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/tiny-server/-/tiny-server-1.1.1.tgz",
"integrity": "sha512-UZdFJFqms0+mvWOs1LRuf2C/ONjERZvaAXXyvqHXGGZtFeFUfeunmVi7OFdI8OgCiBUM1Rq+BfYJ2guVUeXnUg==",
"bin": {
"tiny-server": "bin/index"
}
}
}
}

43
node_modules/tiny-server/README.md generated vendored
View file

@ -1,43 +0,0 @@
# tiny-server
A tiny Web Server
## Install
You can install to global
```shell
npm install -g tiny-server
```
or as a module
```shell
npm install tiny-server
```
## Usage
### global
```shell
tiny-server
```
It will use terminal's current working directory as the web server's root directory.
And the server's port is 3000.
You can specify a path as web server's root directory:
```shell
tiny-server ./www
```
You can export environment `PORT` value as the server's port:
```shell
export PORT=3001 && tiny-server;
```

24
node_modules/tiny-server/bin/index generated vendored
View file

@ -1,24 +0,0 @@
#!/usr/bin/env node
var Server = require("../lib/server");
var argv = process.argv.slice(2);
var cwd = argv[0] || process.cwd();
var port = process.env["PORT"] || 3000;
var server = new Server(cwd);
server.listen(port, function () {
console.log("============= start ============");
console.log(cwd);
console.log("http://localhost:" + port);
}).once("error", function (err) {
if (err.code === "EADDRINUSE") {
console.log("=============== ERROR ===============");
console.error("Port: " + port + " already in use");
console.log("=====================================");
}
process.exit(1);
});

1
node_modules/tiny-server/index.js generated vendored
View file

@ -1 +0,0 @@
module.exports = require("./lib/server");

View file

@ -1,42 +0,0 @@
module.exports = function () {
var unknowMIMEType = "application/octet-stream";
var mimeTypes = new Map([
["txt", "text/plain"],
["htm", "text/html"],
["html", "text/html"],
["xml", "text/xml"],
["css", "text/css"],
["js", "application/javascript"],
["json", "application/json"],
["mp3", "audio/mpeg"],
["wav", "audio/wav"],
["gif", "image/gif"],
["jpg", "image/jpeg"],
["jpeg", "image/jpeg"],
["png", "image/png"],
["bmp", "image/bmp"],
["svg", "image/svg+xml"],
["avi", "video/avi"],
["mp4", "video/mpeg"],
]);
return function (ext) {
if (!ext || typeof ext !== "string") {
return unknowMIMEType;
}
if (/^\./.test(ext)) {
ext = ext.slice(1);
}
ext = ext.toLowerCase();
if (mimeTypes.has(ext)) {
return mimeTypes.get(ext);
} else {
return unknowMIMEType;
}
};
};

24
node_modules/tiny-server/lib/mime.js generated vendored
View file

@ -1,24 +0,0 @@
"use strict";
var detect = require("./detect")();
module.exports = function () {
var mimeTypes = new Map();
var unknowMIMEType = "application/octet-stream";
return function (ext) {
if (!ext) {
return unknowMIMEType;
}
if (mimeTypes.has(ext)) {
return mimeTypes.get(ext);
} else {
var mimeType = detect(ext);
if (!mimeType) {
mimeType = unknowMIMEType;
}
mimeTypes.set(ext, mimeType);
return mimeType;
}
};
};

View file

@ -1,170 +0,0 @@
"use strict";
var fs = require("fs");
var http = require("http");
var path = require("path");
var querystring = require("querystring");
var stream = require("stream");
var util = require("util");
var url = require("url");
var mime = require("./mime")();
var Server = function Server(cwd, middlewares) {
if (!(this instanceof Server)) {
return new Server(cwd, middlewares);
}
if (!cwd) {
cwd = process.cwd();
}
if (typeof middlewares === "function") {
middlewares = [middlewares];
} else if (!Array.isArray(middlewares)) {
middlewares = [];
}
http.Server.call(this);
this.cwd = cwd;
this.middlewares = middlewares;
var requestHandler = this.handler.bind(this);
this.on("request", requestHandler);
this.once("close", function () {
this.removeListener("request", requestHandler);
});
};
util.inherits(Server, http.Server);
Server.prototype.handler = function (req, res) {
var pathname = url.parse(req.url).pathname;
var filename = path.join(this.cwd, path.normalize(querystring.unescape(pathname)));
var that = this;
fs.exists(filename, function (exists) {
if (exists) {
fs.stat(filename, function (err, stats) {
if (err) {
return that.notFound(res);
}
if (stats.isFile()) {
var ext = path.extname(filename);
var mimeType = mime(ext);
res.writeHead(200, {
"Content-Type": mimeType,
"Access-Control-Allow-Origin": "*"
});
fs.createReadStream(filename).pipe(res);
} else if (stats.isDirectory()) {
if (!/\/$/.test(pathname)) {
res.writeHead(301, {
"Location": path.join(pathname, "/")
});
res.end();
return;
}
fs.readdir(filename, function (err, files) {
if (err) {
return that.notFound(res);
}
var len = files.length;
if (!len) {
dir(files);
return;
}
var items = [];
files.forEach(function (file) {
fs.stat(path.join(filename, file), function (err, stats) {
if (!err) {
items.push(stats.isDirectory() ? path.join(file, "/") : file);
}
--len;
if (!len) {
dir(items);
}
});
});
function dir(files) {
res.writeHead(200, {
"Content-Type": "text/html",
"Access-Control-Allow-Origin": "*"
});
res.end(["",
'<!DOCTYPE html>',
'<html>',
' <head>',
' <meta charset="UTF-8">',
' <meta name="viewport" content="width=device-width, initial-scale=1.0">',
' <title>Index of ' + pathname + '</title>',
' </head>',
' <body>',
' <h1>Index of ' + pathname + '</h1>',
' <hr>',
' <ul>',
' <li><a href="..">../</a></li>',
files.map(function (file) {
return ' <li><a href="' + path.join(pathname, file) + '">' + file + '</a></li>';
}).join("\n"),
' </ul>',
' <hr>',
' </body>',
'</html>',
""].join("\n"));
}
});
} else {
that.notFound(res);
}
});
} else {
that.notFound(res);
}
});
};
Server.prototype.notFound = function (res) {
res.writeHead(404, {
"Content-Type": "text/html",
"Access-Control-Allow-Origin": "*"
});
var file = path.join(this.cwd, "404.html");
fs.exists(file, function (exists) {
if (exists) {
fs.createReadStream(file).pipe(res);
} else {
default404Reader().pipe(res);
}
});
function default404Reader() {
var f404 = new stream.Readable();
f404._read = function () {
this.push(["",
'<!DOCTYPE html>',
'<html>',
' <head>',
' <meta charset="UTF-8">',
' <title>Not Found!</title>',
' </head>',
' <body>',
' <h1>File Not Found!</h1>',
' </body>',
'</html>',
""].join("\n"));
this.push(null);
};
return f404;
}
};
module.exports = Server;

View file

@ -1,34 +0,0 @@
{
"name": "tiny-server",
"version": "1.1.1",
"description": "a tiny Web Server",
"main": "index.js",
"scripts": {
"test": "mocha ./test/index.js"
},
"bin": {
"tiny-server": "./bin/index"
},
"keywords": [
"http",
"web",
"server",
"tiny"
],
"author": "zbinlin",
"license": "MIT",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/zbinlin/tiny-server.git"
},
"bugs": {
"url": "https://github.com/zbinlin/tiny-server/issues"
},
"homepage": "https://github.com/zbinlin/tiny-server#readme",
"devDependencies": {
"mocha": "^10.0.0"
}
}

View file

@ -1,23 +0,0 @@
"use strict";
var assert = require("assert");
var detect = require("../lib/detect")();
describe("test lib/detect", function () {
it("非法参数时,返回 application/octet-stream", function () {
assert.equal(detect(), "application/octet-stream");
});
it("扩展名不区别大小写", function () {
var mimeType = "text/plain";
assert.equal(detect("txt"), mimeType);
assert.equal(detect("TXT"), mimeType);
});
it("扩展名前可带 .,如 .txt", function () {
var mimeType = "text/plain";
assert.equal(detect(".txt"), mimeType);
});
it("未知扩展名,返回 application/octet-stream", function () {
assert.equal(detect(".xxx"), "application/octet-stream");
});
});

View file

@ -1,5 +0,0 @@
"use strict";
require("./detect-test");
require("./mime-test");
require("./server-test");

View file

@ -1,19 +0,0 @@
"use strict";
var assert = require("assert");
var mime = require("../lib/mime")();
describe("test lib/mime", function () {
it("非法参数时,返回 application/octet-stream", function () {
assert.equal(mime(), "application/octet-stream");
});
it(".txt 返回 text/plain", function () {
assert.equal(mime(".txt"), "text/plain");
assert.equal(mime(".txt"), "text/plain");
});
it("未知扩展名,返回 application/octet-stream", function () {
assert.equal(mime(".xxx"), "application/octet-stream");
});
});

View file