1.0.8 • Published 4 years ago

@ourstudio/our-http-server v1.0.8

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

Our-server

A small dev server for modern web application development Forked from https://github.com/lukejacksonn/servor

Features

  • 🗂 Serves static content like scripts, styles, images from a given directory
  • 🗜 Uses gzip on common filetypes like html, css, js and json
  • 🖥 Redirects all path requests to a single file for frontend routing

API Usage

Use our-http-server programmatically with node by requiring it as a module in your script:

const ourHttpServer = require('our-http-server').default;
const instance = await ourHttpServer({
  root: '.',
  inject: ''
  port: 8080,
});

The ourHttpServer function accepts a config object with optional props assigned the above default values if none are provided. Calling the ourHttpServer function starts up a new server and returns an object describing its configuration.

const { url, root, protocol, port, ips } = await ourHttpServer(config);

Inject

The inject property accepts a string that gets appended to the servers root document (which is index.html). If no index.html exist, the injectet property will be served. This could be used to inject config or extend the development servers behavior and capabilities to suit specific environments.

const config = require('package.json');
ourHttpServer({ inject: `<script>window.pkg=${config}</script>` });

or inject a .html file

const inject = fs.readFileSync(path.join(__dirname, "sample.html"), "binary")
ourHttpServer({ inject });
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1-alpha16

4 years ago

1.0.1-alpha15

4 years ago

1.0.1-alpha14

4 years ago

1.0.1-alpha12

4 years ago

1.0.1-alpha11

4 years ago

1.0.1-alpha10

4 years ago

1.0.1-alpha8

4 years ago

1.0.1-alpha7

4 years ago

1.0.1-alpha6

4 years ago

1.0.1-alpha5

4 years ago

1.0.1-alpha4

4 years ago

1.0.1-alpha3

4 years ago

1.0.1-alpha2

4 years ago

1.0.1-alpha1

4 years ago

1.0.1-alpha

4 years ago

1.0.0

4 years ago