rjweb-server
Version:
Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS
45 lines (44 loc) • 1.39 kB
TypeScript
import HTMLBuilder, { FnArgument, GetEvery } from "./HTMLBuilder";
/**
* A Utility used for creating Components to use in the `.printHTML()` syntax
* @example
* ```
* const component = new HTMLComponent(...)
* ```
* @since 6.7.0
*/ export default class HTMLComponent<Options extends Record<any, any> = {}> {
private callback;
/**
* Create a new HTML Component
* @example
* ```
* // component.js
* module.exports = new HTMLComponent((html, options) => html
* .t('p', {}, options.text)
* )
*
* // index.js
* const component = require('./component.js')
* const controller = new Server({ })
*
* controller.path('/', (path) => path
* .http('GET', '/', (http) => http
* .onRequest((ctr) => {
* ctr.printHTML((html) => html
* .t('h1', {}, 'Hello matey!')
* .c(component, { text: 'lol' })
* )
* })
* )
* )
* ```
* @since 6.7.0
*/ constructor(
/** The Callback for defining the Component */ callback: (tag: HTMLBuilder, options: Options | undefined) => HTMLBuilder);
/**
* Internal Method for Generating HTML Builder
* @since 6.7.0
*/ protected toBuilder(route: string, fnArguments: FnArgument[], getEvery: GetEvery[], getEveryId: {
n: number;
}, options: Options | undefined): HTMLBuilder;
}