https://github.com/candyframework/luban
An object-oriented efficient MVC and RESTful framework re-write from candyjs
https://github.com/candyframework/luban
Last synced: about 1 year ago
JSON representation
An object-oriented efficient MVC and RESTful framework re-write from candyjs
- Host: GitHub
- URL: https://github.com/candyframework/luban
- Owner: candyframework
- License: mit
- Created: 2025-03-29T05:55:36.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-29T06:11:44.000Z (over 1 year ago)
- Last Synced: 2025-03-29T07:21:52.182Z (over 1 year ago)
- Language: TypeScript
- Size: 117 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## An object-oriented efficient MVC and RESTful framework
This project is rewritten based on the architecture of Project [CandyJs](https://github.com/candyframework)
## Quick start
LuBan application start with an entry file
```typescript
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,
});
```