0.0.29 • Published 4 years ago

@subatomic-rocks/valence v0.0.29

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
4 years ago

Valence: The router for Vanilla Node.js

Valence is meant to be very lightweight, with the minimal impact possible on your server, while being customizable.

Usage is very simple, you simply use Router.on to register all your desired routes and then passes Router.handle to the server.

You can install it into your project by running npm install --save @subatomic-rocks/valence

Warning: This project is currently under active development and is NOT ready for production. Things are subject to change or break, be aware of this.

Example

Here's a small server using it and Node's vanilla HTTP server:

const { Router } = require('@subatomic-rocks/valence')

Router.on('GET', '/{name:[A-z\-]+}', ({ request, response, params }) => {
  response('Hello, this is ' + params.name)
})

Router.on('GET', '/{id:[0-9]+}', ({ request, response, params }) => {
  response('Hello, this is ID ' + params.id)
})

Router.on('GET', '/404', ({ request, response, params }) => {
  response({ message: 'This is a JSON 404' }, 404)
})

require('http').createServer(Router.handle).listen(8080)

You can also check the samples directory for more demos!

Building

To build Valence, first run npm install and then npm run build.

Things that already work

  • Routing
  • Status codes
  • Body parsing (JSON, Form Data)
  • JSON responses
  • Basic middlewares

Things that still need work

  • Tests
  • Body parsing (XML, Multipart)
  • Automated builds
0.0.29

4 years ago

0.0.27

4 years ago

0.0.25

4 years ago

0.0.26

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.18

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.3

4 years ago

0.0.10

4 years ago

0.0.2

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.1

4 years ago