class-forms
v1.2.2
Published
Express & React base framework for simple aspx-like forms
Downloads
23
Maintainers
Readme
Simple express base framework for building forms easily and quickly.
Example Usage
src/pages/index.tsx
class IndexPage extends BaseLayout {
static override path = '/';
showMessage = '';
override useMiddleware(use: UseMiddlewareCallback<DefaultExtendedRequest, DefaultExtendedResponse>) {
super.useMiddleware(use);
this.connectClick(this.buttonClicked);
}
buttonClicked() {
this.showMessage = 'Hello World';
this.req.session!.counter ??= 0;
this.req.session!.counter++;
}
override render(): Promise<any> {
return super.render(async () => ({
title: 'Home',
content: <>
{this.showMessage}
{this.req.session!.counter}
<button name="click" value="buttonClicked">show info</button>
</>
}));
}
}
registerPage(IndexPage);
src/index.ts
import {ClassFormsApp} from 'class-forms';
import './pages/index.js';
const app = new ClassFormsApp();
await app.init();
app.listen();