Jolt Server 一个支持实时重新加载和单页应用程序的Web服务器

网友投稿 793 2022-11-01

Jolt Server 一个支持实时重新加载和单页应用程序的Web服务器

Jolt Server 一个支持实时重新加载和单页应用程序的Web服务器

Jolt Server

A web server supporting live reloading, single page applications, and static file serving.

Installation

You can install jolt-server using npm.

Install using npm:

npm install --save-dev jolt-server

Documentation is availiable here.

Command Line Usage

To launch the dev server, just run the command jolt-server. By default this will put it into a bare bones web server.

You can add additonal functionality by using cli options.

CLI Options:

-p, --port - sets the port the server will run on. (default: 3000)-r, --root - sets the folder that files will be served from. (default: /)-f, --file - sets the fallback file to serve. (default: index.html)-l, --live - sets the server to reload the page when a file is saved.-s, --spa - sets the server to respond to all routes with the fallback file.--key - sets the SSL private key to use for https.--cert - sets the SSL certificate to use for https.

JavaScript Usage

You can use jolt-server in your JavaScript file and pass it the same options as the cli.

Example:

import server from "jolt-server";server({ port: 3000, root: process.cwd(), file: "index.html", live: true, spa: true});

jolt-server also allows you to handle requests yourself. You can do this by passing using the application interface returned by jolt-server. The application interface gives you access to the internal server variable as well as being able to respond to request using get, post, put, patch, and delete functions.

Example:

import server from "jolt-server";const app = server({...});app.get("/home", function(req, res) { res.end("You are at /home");});

Using the application interface, you can also handle parameterized urls. To access the parameters use the req.params property.

Example:

import server from "jolt-server";const app = server({...});app.get("/users/:user", function(req, res) { res.end(`Hello ${req.params.user}!`);});

Why?

Jolt Server was developed to provide a easy setup for developing web apps. Most alternatives use a bunch of dependencies to achieve the desired functionality and as for the case with single page applications, they often dont work for complex routes. Jolt Server solves these problems by not using any dependencies, and making sure that single page applications that utilize push state routing will have no problems being run on this server.

Reporting Issues

If you are having trouble getting something to work with Jolt Server, you can ask in our discord or create a new Issue.

If you find a bug or if something is not working properly, you can report it by creating a new Issue.

If Jolt Server does not fit your needs or is missing a feature you would like to see, let us know! We would greatly appreciate your feedback on it.

You can contact Outwalk Studios directly using support@outwalkstudios.com

License

Jolt Server is licensed under the terms of the MIT license.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:#yyds干货盘点# leetcode算法题:字母异位词分组
下一篇:BleemSync 一个能通过USB存储管理和启动PlayStation经典游戏的应用程序
相关文章

 发表评论

暂时没有评论,来抢沙发吧~