0.1.4 • Published 7 years ago

yattsf v0.1.4

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
7 years ago

#YATTSF

install

npm install yattsf

example

//HelloController.ts
import {routable, Router, HttpRequest, HttpResponse, before} from "yattsf"
@routable()
export class HelloController {
    @Router.get('/hello')
    @Router.get('/hello/(.*)', '*')
    @before(async (req:HttpRequest, res:HttpResponse) => {
        res.addHeader('MIDDLE-WARE', 'test');

        return [req, res]
    })
    async hello(req:HttpRequest, res: HttpResponse) {
        let name = req.pathParams.length > 0 ? req.pathParams[0] : 'World';
        res.setContent(`Hello ${name} !`).addCookie('hello-name', name);

        return [req, res];
    }
}


//app.ts
import {Server, HelloController} from 'yattsf';

const app = new Server();
app.start(3000, '127.0.0.1')

Build and start your app, then try "http://127.0.0.1:3000/hello" and "http://127.0.0.1:3000/hello/YATTSF" in browser.

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.2-dev

7 years ago

0.0.1

7 years ago