npm.io
4.1.0 • Published 8 years agoCLI

thints

Licence
MIT
Version
4.1.0
Deps
2
Vulns
0
Weekly
0

ThinTS

Build Status NPM Version npm

A simple, angular based and typed framework for RestAPIs with node.

Depedencies

* Typescript

* Node.js (tested in >=7.6)

* Express

Installation

$ npm install thints --save

QuickStart

Quick example.

import {MainApplication, MainApplicationConfig, ThModule, ThController, ThRouter, GET} from "thints";

@ThController()
class ExampleController {
    private name = 'ThinTS';
    getMyName() {
        return this.name;
    }
}

@ThRouter('/name')
class ExampleRouter {
    constructor(private exampleCtrl: ExampleController) {}
    
    @GET('/') myname(req: Request, res: Response) {
    	const myname = this.exampleCtrl.getMyName();
    	res.json({myname});
    }
}

@ThModule({
    basePath: '/api',
    controllers: [ ExampleController ],
    routers: [ ExampleRouter ]
})
class MyApiModule {}


const config: MainApplicationConfig = {
    http: {
        autostart: true, // default true
        port: 8000, // default 80
        host: "localhost" // default "localhost"
    },
    https: {
        autostart: true, // default false
        port: 8443, // default 443
        host: "localhost", // default "localhost"
        credentials: {
            keyUrl: "my/key/url.key",
            certificateUrl: "my/cert/url.cert"
        }
    }
};


bootstrap(MyApiModule, config);

A GET request to 'url/api/name' call ExampleRouter and return:

{ "myname": "ThinTs" }

Usage

TypeDocs

Core

MainApplication

ThinTS start point, responsible to bootstrap your module and create initial depedenct tree with essentials imports.

MainApplication.bootstrap(MyModule);

MORE



ThModule

Module is responsible to create scopes and declare components.

MORE



ThController
MORE



ThRouter
MORE



ThModel
MORE



ThMiddleware
MORE



ExpressController
MORE





Routing

Introduction

MORE



GET
MORE



POST
MORE



PUT
MORE



DELETE
MORE



PARAM
MORE

License

MIT

Keywords