{"id":18851604,"url":"https://github.com/eviltik/devsrv","last_synced_at":"2026-02-03T22:30:17.962Z","repository":{"id":57112330,"uuid":"460023565","full_name":"eviltik/devsrv","owner":"eviltik","description":"one line command self signed certificate https server","archived":false,"fork":false,"pushed_at":"2022-03-23T11:26:55.000Z","size":116,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T18:17:24.810Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"devsrv.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eviltik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-16T13:49:07.000Z","updated_at":"2024-06-14T04:31:16.000Z","dependencies_parsed_at":"2022-08-21T10:31:13.087Z","dependency_job_id":null,"html_url":"https://github.com/eviltik/devsrv","commit_stats":null,"previous_names":["eviltik/httpsnode"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eviltik%2Fdevsrv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eviltik%2Fdevsrv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eviltik%2Fdevsrv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eviltik%2Fdevsrv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eviltik","download_url":"https://codeload.github.com/eviltik/devsrv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239788479,"owners_count":19697208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-08T03:35:24.522Z","updated_at":"2026-02-03T22:30:17.918Z","avatar_url":"https://github.com/eviltik.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **devsrv**\n\nA nodejs http(s) server for web development with some cool features. \n\n## **Motivation**\n\nHow many days to test all standalone webservers npm module with all simple features i'm looking for, vs time to code it. I coded it.\n\n## **Command Line Usage**\n\n\u003e You can use `devsrv` as a standalone webserver.\n\n#### Install\n```\n$ npm install -g devsrv\n```\n\n#### Run\n\u003e Go into the directory you want to serve (having an index.html file), then just type\n```\n$ devsrv\nconfig: use config file [...]\nserver: start listening on 192.168.1.36:8443\nserver: ready\n```\n\n#### Options\n```\n$ devsrv\nUsage: devsrv [options]\n\nInstant self signed certificate https web server for developer.\n\nOptions:\n  -V, --version                         output the version number\n  -d, --document-root \u003cdocumentRoot\u003e    DocumentRoot (default: \"./\")\n  -a, --access-log                      Enable access Log\n  -e, --explorer                        Directory listing (default: false)\n  -l, --listening-port \u003clisteningPort\u003e  Listening port (default: 8443)\n  -i, --interface \u003cinterfaceRegexp\u003e     Network interface filter (regular expression)\n  -o, --open-browser                    Open the browser (default: false)\n  -m, --monitor-changes                 Monitor file changes and reload webpage (default: false)\n  -c, --config-file \u003cconfigFile\u003e        Configuration file (default: \"./devsrv.config.js\")\n  -b, --build                           trigger build process (default: false)\n  --build-dst \u003cbuildDst\u003e                build dist directory (default: \"./dist/1.0.0/\")\n  --build-src \u003cbuildSrc\u003e                build src directory (default: \"./public\")\n  -h, --help                            display help for command\n\n```\n\n#### Optional config file\n\n\u003e When starting, the process try to read `./.devsrv.js` in the current directory or in specified `--config-file` directory config option.\n\n\n\n## **Programmatical usage (nodejs)**\n\n\u003e You can use `devsrv` programmatically.\n\n\n#### Install\n```\n$ npm install devsrv\n```\n\n#### Minimal js code\n\n```\nconst Server = require( 'devsrv' );\nconst serverInstance = new Server();\nserverInstance.start();\n```\n\n\n#### With a config object\n\n```\nconst Server = require( 'devsrv' );\n\nconst config = {\n\n    documentRoot: './',\n    listeningPort: 8443,\n    regexpInterface: /wi-fi|eth0/i,\n    browser: true,\n    //features:{\n    // see #Features\n    //}\n};\n\nconst serverInstance = new Server( config );\n\nserverInstance.start();\n```\n\n\n#### Features config\n\n\u003e You can specify theses options if the `config` object.\n\n\n```\nconst config = {\n    documentRoot: './tests',\n    interfaceRegexp: /wi-fi|eth0/i,\n    openBrowser: true,\n    clientRedirects:[\n        {\n            urlSrc:'/',\n            redirectTo:'/tests/index.html'\n        }\n    ],\n    urlRewrites: [\n        {\n            urlSrcRegexp:/^\\/tests2/,\n            replaceWith:'/tests'\n        }\n    ],\n    textReplacements: [\n        {\n            queryVar:'r',\n            queryVarRegexp:/^0\\.[0-9]{3}$/,\n            replaceRegexp:/THREEJSVERSION/g,\n            defaultValue:'0.119',\n            pathRegexp:/\\.(html|js)|(\\/)$/\n        }\n    ],\n    monitorOptions:{\n        enable:false,\n        directories:[ './' ],\n        fileRegexp:/\\.(html|jsm?)$/,\n        excludeRegexp: /node_modules/\n    }\n};\n\nmodule.exports = config;\n\n```\n\n\n## **Use with npm**\n\n\u003e `npm install devsrv` then add start script in your `package.json`\n```\n  \"scripts\": {\n    \"start\": \"node node_modules/devsrv/bin/devsrv.js -d .\"\n  },\n```\nthen\n```\n$ npm start\nconfig: use config file [...]\nserver: start listening on [...]\nserver: ready\n```\n\n## Build process\n\n`devsrv -b` will trigger build process. You can add this in `devsrv.config.js`:\n```\n\"buildOptions\": {\n        \"src\":\"./tests\",\n        \"dst\":\"./dist/v1.0.0/threejs.119\",\n        \"replaceRegexp\":\"THREEJSVERSION\",\n        \"defaultValue\":\"0.119\",\n        \"fileRegexp\":\"\\\\.(html|js)$\"\n    }\n```\n\n* remove dst directory if already exists\n* copy files from src directory into dst directory (recursive), \n* find files match regexp `fileRegexp`, then replace string in file using `replaceRegexp` with value `defaultValue`\n\n## Monitor changes\n\n`devsrv -m` will monitor `documentRoot` recursively and we send an event to the browser \neach time a file or directory has changed. The browser use a SSE client to receive the event.\n\nUnder the wood, `fs.watch` is used. In tests/index.html you will find the peace of \ncode to use to handle Server Side Event Events (\"reload\" event only).\n\n```\nmonitorOptions:{\n    enable:false,\n    directories:[ './' ],\n    fileRegexp:/\\.(html|jsm?)$/,\n    excludeRegexp: /node_modules/\n}\n```\n\n## Debugging\n\n\u003e Set env var `DEBUG` with any value i.e `DEBUG=* devsrv`.\n\n\n## **Changelog**\n\n\u003e **v1.0.0 - 02/18/2022**\n* [x] Add: use HTTPS with generated self signed SSL certificates by default\n* [x] Add: client redirects handler\n* [x] Add: url rewriting handler (proxy)\n* [x] Add: static content webserver with content rewriting\n* [x] Add: open web browser option\n\n\u003e **v1.1.0 - 02/18/2022**\n* [x] Add: static webserver with content rewriting using query string variable\n\n\u003e **v1.3.0 - 02/18/2022**\n* [x] Add: detect Codesandbox, then use http rather than https, because of Codesandbox reverse proxy ssl termination\n\n\u003e **v1.3.1 - 02/21/2022**\n* [x] Change: code refactor\n* [x] Change: change config file name \n* [x] Add: explorer (directory listing)\n* [x] Add: npm build script (releases static files, serverless provider compliant i.e vercel )\n\n\u003e **v1.4.0 - 02/23/2022**\n* [x] Add: monitor file changes and reload web page, no websocket but Server Side Events (SSE)\n* [x] Add: simple access log\n\n\u003e **v1.4.1 - 02/23/2022**\n* [x] Fix: check config before start monitoring file changes\n* [x] Add: simple access log\n\n\u003e **v1.4.2 - 02/24/2022**\n* [x] Fix: use session to store query var value\n\n\u003e **v1.5.0 - 03/01/2022**\n* [x] Add: monitor options, see #1\n* [x] Add: js config file, see #2\n\n\u003e **v1.5.1 - 03/02/2022**\n* [x] Fix package version pb\n\n\u003e **v1.5.1 - 03/02/2022**\n* [x] More delay for file changes\n\n## **Roadmap**\n* [ ] CI tests\n* [ ] Network level throttling (simulate slow network for testing) ?\n* [ ] Systemd template ?\n* [ ] Websocket proxy ?\n* [ ] WebRTC ?\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feviltik%2Fdevsrv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feviltik%2Fdevsrv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feviltik%2Fdevsrv/lists"}