Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/juanjh1/asimilation/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The asi object is the main server instance of the Asimilation framework. It provides methods to configure your server settings and start the HTTP server.
import { asi } from '@asimilation/core';

Type Definition

class Asimilation {
  setup(port: number, path: string): void
  run(): void
  urlManager(): RouteManagerI
  use(): void
  setUrlPrefix(prefix: string): void
}

Methods

setup()

Configures the server port and base path before starting the server.
port
number
required
The port number on which the server will listen for incoming requests.
path
string
required
The base path for all routes. Use an empty string "" for no base path.
return
void
This method does not return a value.
Example:
import { asi } from '@asimilation/core';

// Configure server to run on port 3000 with no base path
asi.setup(3000, '');
// Configure server with base path
asi.setup(8080, '/api/v1');

run()

Starts the HTTP server and begins listening for incoming requests.
return
void
This method does not return a value.
You must call setup() before calling run() to configure the port and base path.
Example:
import { asi } from '@asimilation/core';

asi.setup(3000, '');
asi.run(); // Server starts listening on port 3000

urlManager()

Returns the route manager instance for programmatic route manipulation.
return
RouteManagerI
The route manager interface that allows you to manage routes programmatically.
In most cases, you can use the url export directly instead of calling asi.urlManager().
Example:
import { asi } from '@asimilation/core';

const routeManager = asi.urlManager();
// Use routeManager to manipulate routes programmatically

use()

This method is not yet implemented in the current version.
Intended for adding global middleware to the application.

setUrlPrefix()

This method is not yet implemented in the current version.
Intended for setting a URL prefix for all routes.
prefix
string
The prefix to prepend to all route URLs.

Complete Example

import { asi, url } from '@asimilation/core';

// Define routes
url.addPath('/users', (req, res) => {
  res.sendJson({ users: [] }, 200);
});

url.addPath('/users/:id', (req, res) => {
  const userId = req.params.id;
  res.sendJson({ id: userId }, 200);
});

// Configure and start server
asi.setup(3000, '');
asi.run();

console.log('Server running on http://localhost:3000');

url

Route manager for registering paths

RouteModule

Organize routes with nested modules