API Reference 📚
Introduction 🚀
Abi.js is a lightweight and versatile TypeScript framework designed to be used across Node, Bun, and Deno environments. It allows you to build web applications, manage HTTP routes, and make HTTP requests in a simple and intuitive manner. This section of the documentation serves as a reference for the available APIs in Abi.
Abi.js Class 🏗️
The Abi.js
class is the main class of the framework, combining routing, the server, and the HTTP client into one entity.
Methods
-
get(path: string, handler?: (params: any) => any): this
-
Defines a GET route for the application.
-
Parameters:
path
: The route to associate.handler
: Function to be called when the route is accessed.
-
Example:
-
-
serve(): void
-
Starts the HTTP server and begins listening for requests on the defined routes.
-
Example:
-
-
static get(input: string | Request, options?: RequestInit): Promise<Response>
-
Makes an HTTP GET request using the internal client.
-
Parameters:
input
: The URL orRequest
object.options
: Additional options for the request.
-
Example:
-
Router Class 🛣️
The Router
class handles the routes defined for the application.
Methods
get(path: string, handler?: (params: any) => any): void
-
Defines a GET route for the router.
-
Example:
-
Server Class 🖥️
The Server
class is responsible for serving the routes defined by the router.
Methods
serve(port?: number): void
-
Starts the server on the specified port.
-
Example:
-
Client Class 🌐
The Client
class is used to make HTTP requests.
Methods
static get(input: string | Request, options?: RequestInit): Promise<Response>
-
Makes an HTTP GET request.
-
Example:
-
Abi.js Configuration ⚙️
Abi.js can be configured using the defineConfig
method.
Types
AbiConfig
: Partial or undefined configuration type.Config
: Complete configuration type with all parameters.defaultConfig
: The default configuration used by Abi.
Methods
defineConfig(config: AbiConfig): Config
-
Defines the configuration for Abi by merging default values with those provided.
-
Example:
-
Conclusion 🎯
This section is a starting point for exploring Abi’s features. As development progresses, this reference will be expanded to provide complete details on each available feature and method.