2.5.31 • Published 1 year ago
funckly v2.5.31
... how to create a funckly APPLICATION ...
const server = new VanillaServer(5001)
const application = new Application(server)
... how to create a funckly CONTROLLER ...
interface MyModel {
cat: string
dog?: number | null
tiger: string
}
interface MyFilter {
lion?: boolean
crocodile?: number
}
class MyController implements IController<MyModel, MyFilter> {
public async create(input: ICreateInput<MyModel>): Promise<MyModel> {
// my code
}
public async read(input: IReadInput): Promise<MyModel> {
// my code
}
public async update(input: IUpdateInput<MyModel>): Promise<MyModel> {
// my code
}
public async delete(input: IDeleteInput): Promise<void> {
// my code
}
public async list(input: IListInput<MyFilter>): Promise<IPage<MyModel>> {
// my code
}
}
... how to create a funckly REST UNIT ...
application.createRestUnit<MyModel, MyFilter>('horses')
.setController(() => new MyController())
.setPrevalidation(PrevalidationFormat.Ncode)
.setValidation(model =>
new Validator(model)
.notEmpty(model => model.cat, 'empty cat')
.isString(model => model.cat, 'cat is not string')
.isFloat(model => model.dog, 'dog is not float')
.notEmpty(model => model.tiger, 'empty tiger')
.isUuid(model => model.tiger, 'tiger is not UUID')
)
.setNormalization(normalizer =>
normalizer
.asBoolean('lion')
.asInt('crocodile')
)
... how to create a funckly RPC UNIT ...
interface MyData {
cat: string
dog?: number | null
tiger: string
}
interface MyResult {
lion?: boolean
crocodile?: number
}
class MyResolver implements IResolver<MyData, MyResult> {
public async execute(input: IExecuteInput<MyData>): Promise<MyResult> {
// my code
}
}
application.createRpcUnit<MyData, MyResult>('snake')
.setResolver(() => new MyResolver())
.setValidation(data =>
new Validator(data)
.notEmpty(data => data.cat, 'empty cat')
.isString(data => data.cat, 'cat is not string')
.isFloat(data => data.dog, 'dog is not float')
.notEmpty(data => data.tiger, 'empty tiger')
.isUuid(data => data.tiger, 'tiger is not UUID')
)
... available http calls ...
HTTP POST /horses (create)
HTTP GET /horses/12345 (read)
HTTP PUT /horses/12345 (update)
HTTP PATCH /horses/12345 (read & update)
HTTP DELETE /horses/12345 (delete)
HTTP GET /horses?lion=true (list)
HTTP POST /snake (execute)
... how to create a funckly GRAPHQL UNIT ...
const myRunner: IRunQuery = async (
query: string,
schema: string,
runnable: object
): Promise<IGraphResult> => {
// my code
}
application.createGraphUnit('frog')
.setRunner(myRunner)
.setSchema(`
type Query {
hello: String
}
`)
.setRunnable(() => {
return {
hello() {
return 'Hello World'
}
}
})
2.5.29
1 year ago
2.5.3-1.7
1 year ago
2.5.3-1.5
1 year ago
2.5.3-1.3
1 year ago
2.5.3-1.2
1 year ago
2.5.3-1.1
1 year ago
2.5.30
1 year ago
2.5.31
1 year ago
2.1.5
1 year ago
1.10.20
2 years ago
1.6.17
2 years ago
1.4.20
2 years ago
1.4.19
2 years ago
1.4.5
2 years ago
1.3.14
2 years ago
1.2.22
2 years ago
0.12.17
3 years ago
0.10.15
3 years ago
0.11.17
3 years ago
0.11.23
3 years ago
0.10.4
3 years ago
0.9.16
3 years ago
0.9.13
3 years ago
0.9.2
3 years ago
0.9.1
3 years ago
0.8.31
3 years ago
0.8.25
3 years ago
0.8.24
3 years ago