html -> md
This commit is contained in:
File diff suppressed because one or more lines are too long
347
docs/classes/Router.md
Normal file
347
docs/classes/Router.md
Normal file
@ -0,0 +1,347 @@
|
||||
[**flummpress**](../README.md)
|
||||
|
||||
***
|
||||
|
||||
[flummpress](../README.md) / Router
|
||||
|
||||
# Class: Router
|
||||
|
||||
Defined in: router.ts:7
|
||||
|
||||
## Constructors
|
||||
|
||||
### new Router()
|
||||
|
||||
> **new Router**(): `Router`
|
||||
|
||||
Defined in: router.ts:12
|
||||
|
||||
#### Returns
|
||||
|
||||
`Router`
|
||||
|
||||
## Methods
|
||||
|
||||
### delete()
|
||||
|
||||
> **delete**(`path`, ...`callback`): `this`
|
||||
|
||||
Defined in: router.ts:158
|
||||
|
||||
Registers a route for HTTP DELETE requests.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### path
|
||||
|
||||
The URL path or pattern for the route.
|
||||
|
||||
`string` | `RegExp`
|
||||
|
||||
##### callback
|
||||
|
||||
...`Handler`[]
|
||||
|
||||
An array of middleware or handler functions to execute for this route.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The current instance for method chaining.
|
||||
|
||||
***
|
||||
|
||||
### get()
|
||||
|
||||
> **get**(`path`, ...`callback`): `this`
|
||||
|
||||
Defined in: router.ts:114
|
||||
|
||||
Registers a route for HTTP GET requests.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### path
|
||||
|
||||
The URL path or pattern for the route.
|
||||
|
||||
`string` | `RegExp`
|
||||
|
||||
##### callback
|
||||
|
||||
...`Handler`[]
|
||||
|
||||
An array of middleware or handler functions to execute for this route.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The current instance for method chaining.
|
||||
|
||||
***
|
||||
|
||||
### getRoute()
|
||||
|
||||
> **getRoute**(`path`, `method`): `any`
|
||||
|
||||
Defined in: router.ts:220
|
||||
|
||||
Finds and returns the route matching the given path and method.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### path
|
||||
|
||||
`string`
|
||||
|
||||
The requested path.
|
||||
|
||||
##### method
|
||||
|
||||
`string`
|
||||
|
||||
The HTTP method (e.g., "GET").
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
The matching route or undefined.
|
||||
|
||||
***
|
||||
|
||||
### group()
|
||||
|
||||
> **group**(`basePath`, `callback`): `this`
|
||||
|
||||
Defined in: router.ts:42
|
||||
|
||||
Registers a new route group with common base path and middleware.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### basePath
|
||||
|
||||
The base path or RegExp.
|
||||
|
||||
`string` | `RegExp`
|
||||
|
||||
##### callback
|
||||
|
||||
(`methods`) => `void`
|
||||
|
||||
Callback to define routes within the group.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The Router instance for chaining.
|
||||
|
||||
***
|
||||
|
||||
### head()
|
||||
|
||||
> **head**(`path`, ...`callback`): `this`
|
||||
|
||||
Defined in: router.ts:136
|
||||
|
||||
Registers a route for HTTP HEAD requests.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### path
|
||||
|
||||
The URL path or pattern for the route.
|
||||
|
||||
`string` | `RegExp`
|
||||
|
||||
##### callback
|
||||
|
||||
...`Handler`[]
|
||||
|
||||
An array of middleware or handler functions to execute for this route.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The current instance for method chaining.
|
||||
|
||||
***
|
||||
|
||||
### importRoutesFromPath()
|
||||
|
||||
> **importRoutesFromPath**(`p`, `tpl`): `Promise`\<`Router`\>
|
||||
|
||||
Defined in: router.ts:22
|
||||
|
||||
Dynamically imports routes from a directory and registers them.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### p
|
||||
|
||||
`string`
|
||||
|
||||
Path to the directory containing route files.
|
||||
|
||||
##### tpl
|
||||
|
||||
Optional template instance to use with the routes.
|
||||
|
||||
`false` | [`Tpl`](Tpl.md)
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`Router`\>
|
||||
|
||||
The Router instance for chaining.
|
||||
|
||||
***
|
||||
|
||||
### patch()
|
||||
|
||||
> **patch**(`path`, ...`callback`): `this`
|
||||
|
||||
Defined in: router.ts:169
|
||||
|
||||
Registers a route for HTTP PATCH requests.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### path
|
||||
|
||||
The URL path or pattern for the route.
|
||||
|
||||
`string` | `RegExp`
|
||||
|
||||
##### callback
|
||||
|
||||
...`Handler`[]
|
||||
|
||||
An array of middleware or handler functions to execute for this route.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The current instance for method chaining.
|
||||
|
||||
***
|
||||
|
||||
### post()
|
||||
|
||||
> **post**(`path`, ...`callback`): `this`
|
||||
|
||||
Defined in: router.ts:125
|
||||
|
||||
Registers a route for HTTP POST requests.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### path
|
||||
|
||||
The URL path or pattern for the route.
|
||||
|
||||
`string` | `RegExp`
|
||||
|
||||
##### callback
|
||||
|
||||
...`Handler`[]
|
||||
|
||||
An array of middleware or handler functions to execute for this route.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The current instance for method chaining.
|
||||
|
||||
***
|
||||
|
||||
### put()
|
||||
|
||||
> **put**(`path`, ...`callback`): `this`
|
||||
|
||||
Defined in: router.ts:147
|
||||
|
||||
Registers a route for HTTP PUT requests.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### path
|
||||
|
||||
The URL path or pattern for the route.
|
||||
|
||||
`string` | `RegExp`
|
||||
|
||||
##### callback
|
||||
|
||||
...`Handler`[]
|
||||
|
||||
An array of middleware or handler functions to execute for this route.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The current instance for method chaining.
|
||||
|
||||
***
|
||||
|
||||
### static()
|
||||
|
||||
> **static**(`options`): `this`
|
||||
|
||||
Defined in: router.ts:270
|
||||
|
||||
Serves static files from a specified directory.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### options
|
||||
|
||||
Options for serving static files.
|
||||
|
||||
###### dir?
|
||||
|
||||
`string` = `...`
|
||||
|
||||
Directory containing the static files.
|
||||
|
||||
###### route?
|
||||
|
||||
`RegExp` = `...`
|
||||
|
||||
Regular expression to match the route for static files.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The Router instance for chaining.
|
||||
|
||||
***
|
||||
|
||||
### use()
|
||||
|
||||
> **use**(`obj`): `void`
|
||||
|
||||
Defined in: router.ts:96
|
||||
|
||||
Merges routes or assigns a template instance to the Router.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### obj
|
||||
|
||||
An instance of Router or Tpl.
|
||||
|
||||
[`Tpl`](Tpl.md) | `Router`
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
File diff suppressed because one or more lines are too long
221
docs/classes/Tpl.md
Normal file
221
docs/classes/Tpl.md
Normal file
@ -0,0 +1,221 @@
|
||||
[**flummpress**](../README.md)
|
||||
|
||||
***
|
||||
|
||||
[flummpress](../README.md) / Tpl
|
||||
|
||||
# Class: Tpl
|
||||
|
||||
Defined in: template.ts:4
|
||||
|
||||
## Constructors
|
||||
|
||||
### new Tpl()
|
||||
|
||||
> **new Tpl**(): `Template`
|
||||
|
||||
Defined in: template.ts:11
|
||||
|
||||
#### Returns
|
||||
|
||||
`Template`
|
||||
|
||||
## Methods
|
||||
|
||||
### escape()
|
||||
|
||||
> **escape**(`str`): `string`
|
||||
|
||||
Defined in: template.ts:147
|
||||
|
||||
Escapes a string for safe usage in HTML.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### str
|
||||
|
||||
`string`
|
||||
|
||||
The string to escape.
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
The escaped string.
|
||||
|
||||
***
|
||||
|
||||
### forEach()
|
||||
|
||||
> **forEach**(`o`, `f`): `void`
|
||||
|
||||
Defined in: template.ts:163
|
||||
|
||||
Iterates over an object or array and applies a callback function.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### o
|
||||
|
||||
`any`
|
||||
|
||||
The object or array to iterate over.
|
||||
|
||||
##### f
|
||||
|
||||
(`value`, `key`) => `void`
|
||||
|
||||
The callback function.
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
***
|
||||
|
||||
### getMtime()
|
||||
|
||||
> **getMtime**(`file`): `number`
|
||||
|
||||
Defined in: template.ts:180
|
||||
|
||||
Retrieves the last modification time of a file.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### file
|
||||
|
||||
`string`
|
||||
|
||||
The file path to check.
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
The last modification time in milliseconds.
|
||||
|
||||
***
|
||||
|
||||
### render()
|
||||
|
||||
> **render**(`file`, `data`, `locals`): `string`
|
||||
|
||||
Defined in: template.ts:103
|
||||
|
||||
Renders a template with the provided data and local variables.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### file
|
||||
|
||||
`string`
|
||||
|
||||
The name of the template file (without extension).
|
||||
|
||||
##### data
|
||||
|
||||
`Record`\<`string`, `any`\> = `{}`
|
||||
|
||||
Data object to inject into the template.
|
||||
|
||||
##### locals
|
||||
|
||||
`Record`\<`string`, `any`\> = `{}`
|
||||
|
||||
Local variables to be used within the template.
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
The rendered HTML string.
|
||||
|
||||
***
|
||||
|
||||
### setCache()
|
||||
|
||||
> **setCache**(`cache`): `void`
|
||||
|
||||
Defined in: template.ts:48
|
||||
|
||||
Enables or disables the template caching mechanism.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### cache
|
||||
|
||||
`boolean`
|
||||
|
||||
If true, enables caching.
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
***
|
||||
|
||||
### setDebug()
|
||||
|
||||
> **setDebug**(`debug`): `void`
|
||||
|
||||
Defined in: template.ts:23
|
||||
|
||||
Enables or disables debug mode.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### debug
|
||||
|
||||
`boolean`
|
||||
|
||||
If true, enables debug mode.
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
***
|
||||
|
||||
### setGlobals()
|
||||
|
||||
> **setGlobals**(`globals`): `void`
|
||||
|
||||
Defined in: template.ts:40
|
||||
|
||||
Sets global variables to be used in all templates.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### globals
|
||||
|
||||
`Record`\<`string`, `any`\>
|
||||
|
||||
An object containing global variables.
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
***
|
||||
|
||||
### setViews()
|
||||
|
||||
> **setViews**(`views`): `void`
|
||||
|
||||
Defined in: template.ts:31
|
||||
|
||||
Sets the directory for template files and preloads all templates.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### views
|
||||
|
||||
`string`
|
||||
|
||||
The directory path for template files.
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
File diff suppressed because one or more lines are too long
100
docs/classes/default.md
Normal file
100
docs/classes/default.md
Normal file
@ -0,0 +1,100 @@
|
||||
[**flummpress**](../README.md)
|
||||
|
||||
***
|
||||
|
||||
[flummpress](../README.md) / default
|
||||
|
||||
# Class: default
|
||||
|
||||
Defined in: index.ts:12
|
||||
|
||||
## Constructors
|
||||
|
||||
### new default()
|
||||
|
||||
> **new default**(): `Flummpress`
|
||||
|
||||
Defined in: index.ts:18
|
||||
|
||||
#### Returns
|
||||
|
||||
`Flummpress`
|
||||
|
||||
## Properties
|
||||
|
||||
### middleware
|
||||
|
||||
> **middleware**: `Handler`[]
|
||||
|
||||
Defined in: index.ts:16
|
||||
|
||||
***
|
||||
|
||||
### router
|
||||
|
||||
> **router**: [`Router`](Router.md)
|
||||
|
||||
Defined in: index.ts:14
|
||||
|
||||
***
|
||||
|
||||
### tpl
|
||||
|
||||
> **tpl**: [`Tpl`](Tpl.md)
|
||||
|
||||
Defined in: index.ts:15
|
||||
|
||||
## Methods
|
||||
|
||||
### listen()
|
||||
|
||||
> **listen**(...`args`): `this`
|
||||
|
||||
Defined in: index.ts:80
|
||||
|
||||
Starts the HTTP server and begins listening for incoming requests.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### args
|
||||
|
||||
...`any`[]
|
||||
|
||||
Arguments passed to `http.Server.listen`.
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
- The current instance for chaining.
|
||||
|
||||
***
|
||||
|
||||
### use()
|
||||
|
||||
> **use**(`plugin`): `this`
|
||||
|
||||
Defined in: index.ts:37
|
||||
|
||||
Adds a plugin to the application, which can be a Router instance, Tpl instance,
|
||||
or a middleware handler function. The method determines the type of the plugin
|
||||
and performs the appropriate action.
|
||||
|
||||
- If the plugin is an instance of `Router`, it is added to the application's router.
|
||||
- If the plugin is an instance of `Tpl`, it sets the application's template engine.
|
||||
- If the plugin is a middleware function, it is added to the middleware stack.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### plugin
|
||||
|
||||
The plugin to add, which can be a `Router` instance,
|
||||
a `Tpl` instance, or a middleware handler function.
|
||||
|
||||
[`Tpl`](Tpl.md) | [`Router`](Router.md) | `Handler`
|
||||
|
||||
#### Returns
|
||||
|
||||
`this`
|
||||
|
||||
The current instance for method chaining.
|
Reference in New Issue
Block a user