0.0.8-3 • Published 7 years ago

capivara v0.0.8-3

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

In development.

Capivara helps you to create a modularized express application using Typescript, and it helps you to make your app more testable.

Set up Capivara

In your project, just install Capivara

npm install --save capivara

Then, create a Typescript file to bootstraps Capivara.

import { Server } from 'capivara';

Server.bootstraps().start(); // server will start on port 3001

Example

File1.ts:

import { Route, RouteDef, HttpMethod } from 'capivara';

@Route({
    path: '/',
    method: HttpMethod.GET
})
export class MyController implements RouteDef {

    private _test(): void {
        console.log('Just a test');
    }

    Route(req, res, next) {
        this._test();
        res.send('Hello World');
    }

} 

Router.ts

import { MyController } from './File1'
import { Router } from 'capivara';

@Router({
    mountPoint: '/api',
    routes: [MyController],
    routers: [/** You can create a deep tree of routers */]
})
export class MyRouter { }

Bootstrap.ts

import { ConfigSetter, Server } from 'capivara';
import { MyRouter } from './Router';

let config: ConfigSetter = new ConfigSetter();

/** use middlewares */
config.middleware(bodyParser.json());
config.middleware(compression());

/** define routers */
config.setRouter(MyRouter);

/** configure server */
let server: Server = Server.bootstraps(config);

/** start server */
server.start(4000);

Docs

For now, looks at code. It's in development, so, big changes can happen.

0.0.8-3

7 years ago

0.0.8-2

7 years ago

0.0.8-1

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago