{"id":36544890,"url":"https://github.com/ansiboy/node-web-server-plus","last_synced_at":"2026-01-12T05:58:27.254Z","repository":{"id":48142545,"uuid":"162579074","full_name":"ansiboy/node-web-server-plus","owner":"ansiboy","description":"Node Web Server 的加强版本，再 Node Web Server 的基础上集成更多的功能。","archived":false,"fork":false,"pushed_at":"2022-07-22T02:52:12.000Z","size":934,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T17:28:36.595Z","etag":null,"topics":["node-web-server"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ansiboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-20T12:50:22.000Z","updated_at":"2022-04-09T01:13:36.000Z","dependencies_parsed_at":"2022-08-29T04:40:16.017Z","dependency_job_id":null,"html_url":"https://github.com/ansiboy/node-web-server-plus","commit_stats":null,"previous_names":["ansiboy/node-mvc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ansiboy/node-web-server-plus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansiboy%2Fnode-web-server-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansiboy%2Fnode-web-server-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansiboy%2Fnode-web-server-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansiboy%2Fnode-web-server-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ansiboy","download_url":"https://codeload.github.com/ansiboy/node-web-server-plus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansiboy%2Fnode-web-server-plus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28335979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["node-web-server"],"created_at":"2026-01-12T05:58:24.888Z","updated_at":"2026-01-12T05:58:27.239Z","avatar_url":"https://github.com/ansiboy.png","language":"TypeScript","readme":"# Node Web Server Plus\n\n前言：作者在 nodejs 开发的时候发现一个问题，就是没有一个好用一点的 Web Server（类似于 IIS） ，有时候写个简单的东西，都要安装一大堆东西。于是作者开发一款 Node Web Server 。\n然后发现还是不够好用，但是又不想把 Node Web Server 的代码搞得太复杂，于是对 Node Web Server 进行二次封装，开发了这个名为 Node Web Server Plus 的软件。\n\n[Node Web Server](https://github.com/ansiboy/node-web-server) 的加强版本，再 Node Web Server 的基础上集成更多的功能。\n\n1. 提供命令行启动\n1. 提供了配置文件进行设置\n1. 集成了 Babel，把 ts，js 转换为 amd js\n1. 集成了 [MVC](https://github.com/ansiboy/node-web-server-mvc) 功能\n1. 集成了 Less，Less 转 CSS\n1. 提供了插件加载机制\n\n## 安装使用\n\n软件提供了 npm 的安装方式，在控制台输入下面的命令\n\n```\nnpm i -g maishu-nwsp\n```\n\n软件提供了命令行的方式来使用\n\n```\nnwsp -d \u003cwebsite path\u003e -p \u003cport\u003e\n```\n\n-d 必填，后面的参数 \\\u003cwebsite path\\\u003e 为网站文件夹\n-p 可选，后面的参数 \\\u003cport\u003e 为网站端口，默认值为 9868\n\n### 网站目录\n\n一个典型的网站文件夹应该如下：\n\n```\n根目录\n├── controllers\n|   └── home.js\n├── node_modules\n├── public\n|   └── dynamic\n|   └── index.html\n└── package.json\n```\n\n- controllers 文件夹用来放置控制器文件\n- public 文件夹为公开的文件夹，可以通过 http 请求进行访问\n- dynamic 用于存放动态脚本文件，关于动态脚本文件，参考 [Node Web Server](\u003c(https://github.com/ansiboy/node-web-server)\u003e)\n\n**示例**\n\n下面的示例演示一个最为简单的网页显示\n\n创建一个名为 demo 的文件夹如下：\n\n```\ndemo\n├── public\n|   └── index.html\n```\n\nindex.html 文件\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eHello World\u003c/h1\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n运行命令\n\n```\nnwsp -d demo\n```\n\n在浏览器输入 http://127.0.0.1:9868 可以看到\n\n```\nHello World\n```\n\n## TS 文件的转换\n\n文件夹如下\n\n```\ndemo\n├── public\n|   └── index.html\n|   └── index.ts\n```\n\nindex.html 文件\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\u003c/head\u003e\n  \u003cbody\u003e\n    \u003cscript src=\"./index.ts\"\u003e\u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nindex.ts 文件\n\n```ts\nlet hello: string = 'Hello'\nlet world: string = 'World'\ndocument.body.innerHTML = hello + ' ' + world\n```\n\n运行命令\n\n```\nnwsp -d demo\n```\n\n在浏览器输入 http://127.0.0.1:9868 可以看到\n\n```\nHello World\n```\n\n在浏览器输入 http://127.0.0.1:9868/index.ts 可以看到\n\n```js\n'use strict'\n\nlet hello = 'Hello'\nlet world = 'World'\ndocument.body.innerHTML = hello + ' ' + world\n```\n\n## LESS 文件转换\n\n文件夹如下\n\n```\ndemo\n├── public\n|   └── index.html\n|   └── index.less\n```\n\nindex.html 文件内容如下：\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"./index.less\" /\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eHello World\u003c/h1\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nindex.less 文件内容如下：\n\n```less\n@color: red;\n\nh1 {\n  color: @color;\n}\n```\n\n运行命令\n\n```\nnwsp -d demo\n```\n\n在浏览器输入 http://127.0.0.1:9868 可以看到红色的 ”Hello World“\n\n\u003cdiv style=\"color:red\"\u003eHello World\u003c/div\u003e\n\n## 动态脚本\n\nnode-web-server 支持使用 js 编写的动态脚本文件，动态脚本文件需要放在名为特定的文件夹，该文件夹默认为 dynamic，可以同通过配置修改该文件夹路径。\n\n\n**示例**\n\n文件夹如下\n\n```\ndemo\n├── public\n|   └── dynamic\n|       └── hello-world.js\n```\n\nhello-world.js 文件如下\n\n```js\nexports.default = function () {\n    return {\n        content: \"hello world\",\n        headers: { \"Content-Type\": \"text/plain\" }\n    }\n}\n```\n\n在浏览器输入：http://127.0.0.1:9868/dynamic/hello-world.js 可以看到：\n\n```\nhello world\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansiboy%2Fnode-web-server-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fansiboy%2Fnode-web-server-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansiboy%2Fnode-web-server-plus/lists"}