Popular
Documentations
Application examples
- Basic + OpenAPI v3 generator (Swagger)
- CORS middleware
- SPA middleware
- Static content middleware
- Database PostgreSQL
- Template render: Dejs, Handlebars, and Eta
- Body transform, validator
- DI
- Docker
Simple example:
import { Controller, Get, Area, App } from 'https://deno.land/x/alosaur/mod.ts'
@Controller('/home')
export class HomeController {
@Get('/text')
text() {
return "Hello world";
}
@Get('/json')
json() {
return {"text":"test"};
}
}
@Area({
controllers: [HomeController]
})
export class HomeArea {
}
const app = new App({
areas: [HomeArea]
});
app.listen();
Set, get and delete cookie
import { Cookie, setCookie, getCookies, delCookie } from "https://deno.land/std/http/cookie.ts";
...
@Get('/view')
view(Req() request: ServerRequest, @Res() response: Response) {
const cookies = getCookies(request);
const cookie: Cookie = { name: "Space", value: "Cat" };
setCookie(response, cookie);
delCookie(response, "deno");
return View(result);
}