class-forms
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published
Logo

Class Forms

Build License License Version


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();

Package Sidebar

Install

npm i class-forms

Weekly Downloads

12

Version

1.2.2

License

MIT

Unpacked Size

31.4 kB

Total Files

24

Last publish

Collaborators

  • ido.pluto