The AntelopeJS contract for HTTP and WebSocket APIs. Declare controllers and routes with decorators and let the implementing module serve them.
Documentation · Implementations · All interfaces and providers
ControllerandPartialControllergroup routes under a base path, with nesting throughextend.@Get,@Post,@Put,@Delete, and@Routemap methods to endpoints.@Prefix,@Postfix, and@Monitorrun before or after them.@Parameter,@MultiParameter,@JSONBody,@RawBody,@BodyStream,@Context,@Result, and@WriteStreaminject request data into handler arguments.@Transformchanges a value before the handler receives it.HTTPResultsets the status, headers, and body of a response. The body is anHTTPBody, which is a string or a value thatJSON.stringifywrites as JSON.@WebsocketHandlerand@Connectionhandle WebSocket connections on the same controllers.
| Module | Notes |
|---|---|
@antelopejs/api |
HTTP and WebSocket server, CORS settings |
Add the interface to the module that declares routes:
pnpm add @antelopejs/interface-apiThen add an implementation to the project:
ajs project modules add @antelopejs/apiimport {
Controller,
Get,
HTTPResult,
JSONBody,
Parameter,
Post,
} from "@antelopejs/interface-api";
export class BookController extends Controller("/books") {
@Get(":id")
async getBook(@Parameter("id") id: string) {
return new HTTPResult(200, { id });
}
@Post("")
async createBook(@JSONBody() body: { title: string }) {
return new HTTPResult(201, body);
}
}The decorators register the routes when JavaScript defines the class. @antelopejs/api serves GET /books/:id and POST /books.
The module declares this peer dependency:
| Package | Supported | Tested with |
|---|---|---|
@antelopejs/interface-core |
>=0.4.0 <1.0.0 |
0.4.0 |
Read CONTRIBUTING.md before you open a pull request. The local checks are:
pnpm install
pnpm run checksAntelopeJS is the TypeScript framework where modules depend on contracts and the application chooses the provider. AntelopeJS DMS is built on it.
| Area | Contracts | Providers |
|---|---|---|
| API | interface-api · interface-api-util · interface-data-api |
api |
| Auth | interface-auth |
auth-jwt |
| Database | interface-database · interface-database-decorators · interface-database-catalog · interface-mongodb · interface-rethinkdb |
postgres · mongodb · rethinkdb |
| Redis | interface-redis · interface-redis-scheduler |
redis |
interface-email |
nodemailer · brevo |
|
| File storage | interface-file-storage |
file-storage-local · file-storage-s3 |
| Payments | interface-payment · interface-subscriptions · interface-stripe |
stripe · mollie · checkout-com · payment-subscriptions |