4.1.0 • Published 6 years ago
thints v4.1.0
ThinTS
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][docs-mainapp]
ThModule
Module is responsible to create scopes and declare components.
[MORE][docs-thmodule]
ThController
[MORE][docs-thcontroller]
ThRouter
[MORE][docs-throuter]
ThModel
[MORE][docs-thmodel]
ThMiddleware
[MORE][docs-thmodule]
ExpressController
[MORE][docs-thmiddleware]
Routing
Introduction
[MORE][docs-thmodule]
GET
[MORE][docs-get]
POST
[MORE][docs-post]
PUT
[MORE][docs-put]
DELETE
[MORE][docs-delete]
PARAM
[MORE][docs-param]
License
[MIT][license-url]