Skip to content

candyframework/luban

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An object-oriented efficient MVC and RESTful framework

This project is rewritten based on the architecture of Project CandyJs

Quick start

LuBan application start with an entry file

import type HttpRequest from '@luban/framework/http/HttpRequest';
import Main from '@luban/framework';
import Application from '@luban/framework/rest/Application';
import HttpResponse from '@luban/framework/http/HttpResponse';
import Hook from '@luban/framework/core/Hook';

Hook.use(async (_req: Request, hook: Hook) => {
    console.log('hook1 run');
    return await hook.next();
});
Hook.use(async (_req: Request, hook: Hook) => {
    console.log('hook2 run');
    return await hook.next();
});

const app = new Application({
    id: 'rest',
    debug: true,
});

app.get('/', async (_request: HttpRequest) => {
    return HttpResponse.fromText('Hello, world!');
});

app.get('/user/{id}', async (_request: HttpRequest, parameters: any) => {
    return HttpResponse.fromText('User ' + parameters.id);
});

const main = new Main(app);
main.listen({
    port: 2333,
});

About

An object-oriented efficient MVC and RESTful framework re-write from candyjs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors