-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
880cf2b
commit d956136
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Interfaces", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Orion Interface Definitions" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Database Interface | ||
|
||
```bash | ||
Location: src/interfaces/IDatabase.js | ||
``` | ||
|
||
## Purpose | ||
The `DatabaseInterface` interface provides a blueprint for creating database connection classes in Orion. By standardizing essential functions like `connect`, `getClient`, and `close`, this interface ensures consistent database management across the application. Additionally, by extending the `Singleton` utility, it enforces the singleton pattern, making sure only one instance of a database connection exists. | ||
|
||
## Key Features | ||
- **Singleton Pattern:** Only one instance per database connection class, promoting efficient resource usage. | ||
- **Standardized Methods:** Requires subclasses to implement key methods for managing database connections. | ||
- **Type Safety**: Prevents direct instantiation, making it impossible to use the interface without subclassing and implementing required methods. | ||
|
||
## Method Descriptions | ||
|
||
- `constructor()`: | ||
- **Utility:** Initializes the database interface instance. | ||
- **Purpose:** Ensures that `DatabaseInterface` cannot be instantiated directly. If an attempt is made to instantiate it without subclassing, it throws an error. | ||
- **Why?:** Enforcing this restriction encourages developers to create database connection subclasses tailored to specific database types. | ||
|
||
- `connect()`: | ||
- **Utility:** Establishes a connection to the database. | ||
- **Purpose:** This is an abstract method that must be implemented by any subclass. The specific connection logic for the database should be defined here. | ||
- **Why?:** A standardized connect method ensures that every database connection class provides a way to open a connection, following a predictable pattern across the application. | ||
|
||
- `getClient()`: | ||
- **Utility:** Retrieves the database client instance. | ||
- **Purpose:** This method is abstract and must be implemented in subclasses. It provides access to the raw client or connection object, enabling interaction with the database. | ||
- **Why?:** Accessing the client directly is essential for executing queries or commands. This method ensures that all subclasses expose a getClient method for consistent database interactions. | ||
|
||
- `close()`: | ||
- **Utility:** Closes the database connection. | ||
- **Purpose:** Another abstract method, requiring subclasses to implement specific logic for closing the database connection. | ||
- **Why?:** Properly closing database connections helps prevent memory leaks and connection saturation. | ||
|
||
:::info Information | ||
Orion offers flexibility for you to extend and establish your own database connections. We've detailed how to do this in the `Extension Guide`. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Middleware Interface | ||
|
||
```bash | ||
Location: src/interfaces/IMiddleware.js | ||
``` | ||
|
||
## Purpose | ||
The `IMiddleware` interface provides a consistent structure for middleware components in Orion. The interface enforces a single method, `handle`, which each middleware must implement. | ||
|
||
## Key Features | ||
- **Abstract Base Class:** Prevents direct instantiation, requiring middleware classes to subclass and implement handle. | ||
- **Consistent Method Signature:** The `handle` method provides a unified way to process incoming requests. | ||
- **Easy Extensibility:** Developers can easily create custom middleware with predictable behavior. | ||
|
||
## Method Descriptions | ||
|
||
- `constructor()`: | ||
- **Utility:** Initializes the middleware interface. | ||
- **Purpose:** Ensures that IMiddleware cannot be instantiated directly. Throws an error if an instance of IMiddleware is created without subclassing. | ||
- **Why?:** This restriction enforces subclassing, promoting a consistent structure and requiring subclasses to define middleware-specific behavior in the handle method. | ||
|
||
- `handle(req, res, next)`: | ||
- **Utility:** Processes incoming HTTP requests. | ||
- **Purpose:** This abstract method must be implemented by subclasses. It receives the `req`, `res`, and `next` parameters to handle the request, response, and the next middleware in the stack. | ||
- **Why?:** By enforcing the handle method, the interface ensures that all middleware subclasses provide a standardized approach to request handling, making middleware easier to understand and manage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"label": "Tutorial - Extras", | ||
"position": 3, | ||
"position": 5, | ||
"link": { | ||
"type": "generated-index" | ||
} | ||
|