This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__decorate([ | |
noop(), | |
__metadata("design:type", Function), | |
__metadata("design:paramtypes", [Number, Number]), | |
__metadata("design:returntype", Array) | |
], AnimalClass.prototype, "list", null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "reflect-metadata" | |
const parameterType = Reflect.getOwnMetadata("design:paramtypes", | |
AnimalClass.prototype, "list") | |
const returnType = Reflect.getOwnMetadata("design:returntype", | |
AnimalClass.prototype, "list") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class TodoController { | |
@put('/todos/{id}') | |
async replaceTodo( | |
@param.path.number('id') id: number, | |
@requestBody() todo: Todo): Promise<boolean> { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class TodosController { | |
// PUT /todos/:id | |
@route.put(":id") | |
async replaceTodo(id: number, todo: Todo): Promise<boolean> { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@domain() | |
export class Todo { | |
constructor( | |
public id: number, | |
public title: string, | |
public description:string | |
){} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
kind: "Class", | |
name: "MyAwesomeClass", | |
... | |
methods: [{ | |
kind: "Method", | |
name: "myAwesomeMethod", | |
returnType: Number, | |
decorators: [{ | |
type: "Cache", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class TodosController { | |
//POST /todo | |
save(data: Todo) { | |
return db("Todo").insert({ ...data }) | |
} | |
//GET /todo/id | |
get(id: number) { | |
return db("Todo").where({ id }).first() | |
} | |
//PUT /todo/id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Plumier, { route, WebApiFacility } from "plumier" | |
// controller | |
export class SayController { | |
// GET /say/hello?name=<string>&age=<number> | |
@route.get() | |
hello(name:string, age:number){ | |
return { message: `Hello ${name}, you are ${age} years old!` } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//base domain | |
@domain() | |
export class Animal { | |
constructor(public name:string, public age:number){} | |
} | |
//cat domain | |
@domain() | |
export class Cat extends Animal { | |
constructor(public name:string, public age:number, public microChip:string){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@domain() | |
export class User { | |
constructor( | |
public id:number, | |
public name:string, | |
public birthDate:Date, | |
public role: "User" | "Admin", | |
public deleted:boolean | |
){} | |
} |