3.0.2 • Published 4 years ago

servie-route v3.0.2

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
4 years ago

Servie Route

NPM version NPM downloads Build status Test coverage

Simple route middleware for Servie using Path-To-Regexp.

Installation

npm install servie-route --save

Usage

The package exposes common HTTP methods: get, head, put, post, patch, del, and options.

import { get, post } from "servie-route";
import { compose } from "throwback";

const animals = ["rabbit", "dog", "cat"];

const app = compose([
  get("/pets", function() {
    return new Response(animals.join("\n"));
  }),
  get("/pets/:id", function(req) {
    return new Response(animals[Number(req.params[0])]);
  })
]);

Composition

If you need raw control, the package also exposes the internally used functions: method and path.

  • method(method, fn) - Match an incoming request against a HTTP method.
  • path(path, fn, options?) - Match an incoming request against a path-to-regexp path.

TypeScript

This project is written using TypeScript and publishes the definitions directly to NPM.

License

Apache 2.0

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.1.0

4 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

6 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago