0.0.5 • Published 4 years ago

ubik v0.0.5

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

ubik

A live-server kind of thing for prototyping locally using ES6 import/export.

Usage

Install globally

npm install -g ubik

Then serve your current working directory

ubik

ubik expects two directories to be present:

project
├─ pages
└─ public

Page functions

Any route that doesn't match a static file will be served from /pages, for example:

RouteFile
localhost:3000/pages/index.js
localhost:3000/banana/pages/banana.js or /pages/banana/index.js

Pages can be nested to make any route you like.

To create a valid page, export a default function with node http request and response arguments then send something back:

export default (req, res) => {
  res.end('Hello, world!');
}

The req object is decorated with pathname and query properties.

http://localhost:3000/banana?brand=chiquita
req.pathname // '/banana'
req.query // { brand: 'chiquita' }

Static files

Anything in /public is served as expected.

0.0.5

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.4

4 years ago

0.0.1

4 years ago

0.0.0

8 years ago