Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @t2ee/vader with all npm packages installed. Try it out:

require("@t2ee/core/package.json"); // @t2ee/core is a peer dependency. require("@t2ee/sl4js/package.json"); // @t2ee/sl4js is a peer dependency. require("koa/package.json"); // koa is a peer dependency. require("typescript/package.json"); // typescript is a peer dependency. require("reflect-metadata/package.json"); // reflect-metadata is a peer dependency. var vader = require("@t2ee/vader")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@t2ee/vader v1.0.3

t2ee router component

IMPORTANT !!

@t2ee/vader has now moved towards 1.x versions, with brand new mechanisms (though, 99% like apis as 0.x versions). For legacy 0.x versions, please see 0.x branch.

Introducation

@t2ee/vader is a routing component (with JAX-RS like grammars). It is to be used with koa@2.

For detailed introduction and examples, please visit vader.t2ee.org

Installation

npm i reflect-metadata @t2ee/core @t2ee/sl4js koa@2 @t2ee/vader -S

Example

import 'reflect-metadata';
import * as Koa from 'koa';
import {
    Path,
    Router,
    QueryParam,
    Response,
    GET,
} from '@t2ee/vader';

const router = Router.newInstance();

@Path('')
class Controller {

    @GET
    @Path('/say')
    say(@QueryParam('message') message: string) {
        const response = new Response();
        response.body = message;
        return response;
    }
}

router.use(Controller);
const app = new Koa();
app.use(router.routes());
app.listen(8080);
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free