An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
September 13, 2022 08:58 pm GMT
Original Link: https://dev.to/haikelfazzani/servino-2698
Servino
Servino
Fast and simple zero-configuration dev server with hot reload.
Install
$ npm i -g servino# or$ npm i servino --save-dev
CLI
# Getting startsv -r src -p 3000# long commandsv --port 8125 --delay 500 --inject --wdir tests,public --ignore node_modules,.git# shortsv -p 8125 -d 500 -w tests,public -i node_modules,.git -s tests/cert.pem,tests/key.pem
API
const servino = require('servino')servino(options?: object) : void
Available Options
options/Command | Example | Description |
---|---|---|
--config or -c | null | specify where config json file is located (directory) |
--host or -h | '127.0.0.1' | Set the server address |
--port or -p | 8125 | Set the server port. |
--root or -r | 'public' | Set root directory that\'s being served. Default: current working directory |
--ignore or -i | node_modules,.git | which\'s files or folders should be ignored (Watch ignore) |
--wdir or -w | tests,public | Paths to watch for changes. Default: watch everything under root directory |
--delay or -d | 100 | Realod time between changes (ms). |
--inject | true | Inject Css and Javascript files without refresh the browser |
--open or -o | true | Open url on the browser |
--verbose or -v | true | Show logs |
--ssl or -s | tests/cert.pem,tests/key.pem | ssl certifications |
Config file: servino.json
/* command: sv -c tests A config file can take any of the command line arguments as JSON key values, for example:*/{ "host": "0.0.0.0", "port": 8125, "root": ".", "wdir": [ "app", "src" ], "delay": 100, "ignore":[ "node_modules", "dist", ".git" ], "inject": true, "open": true, "verbose": true, "ssl": [ "tests/cert.pem", "tests/key.pem" ]}
TLS/SSL
First, you need to make sure that openssl is installed correctly, and you have key.pem and cert.pem files. You can generate them using this command:
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
Then you need to run the server with -s for your certificate files.
# Note: order importantservino -s tests/cert.pem,tests/key.pem
Todo
- [ ] Support SPA
Notes
- All pull requests are welcome, feel free.
Author
License
MIT
Original Link: https://dev.to/haikelfazzani/servino-2698
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To