jolt-serverdeprecated

A web server supporting live reloading and single page applications.

Usage no npm install needed!

<script type="module">
  import joltServer from 'https://cdn.skypack.dev/jolt-server';
</script>

README

Jolt Server

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

Actions License Chat Server Donate


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.