HTTP Package Entry Point (index.ts
)
This file serves as the main entry point for the @sodacore/core
HTTP module. It re-exports all primary decorators, context classes, services, providers, utilities, and types, making them available for import from a single location. The default export is the HttpPlugin
for easy integration with the Sodacore application.
Features
- Centralized Exports: Exposes all HTTP-related decorators, context classes, services, providers, and utilities for easy import.
- Decorator Exports: Provides decorators for controllers, HTTP methods, middleware, parameter injection, and response transformation.
- Context and Service Exports: Exports the main HTTP and SSE context classes, HTTP service, and SSE connections provider.
- Utility Exports: Exports helper utilities for route matching, cookie parsing, and response conversion.
- Type Exports: Exports core HTTP types for strong typing in controllers, middleware, and plugins.
- Default Plugin Export: Exports
HttpPlugin
as the default, enabling quick registration with the Sodacore application.
Usage
Import HTTP features directly from the package root:
typescript
import HttpPlugin, {
Controller,
Get,
Post,
Put,
Patch,
Delete,
Head,
Options,
Middleware,
Transform,
Body,
Cookies,
Headers,
Method,
Params,
Query,
Request,
Server,
Url,
HttpContext,
SseContext,
HttpService,
SseConnectionsProvider,
Utils,
IConfig,
IMiddleware,
IServerContext,
IControllerMetaMethodItem,
} from '@sodacore/core/http';
Register the plugin with your Sodacore application:
typescript
import HttpPlugin from '@sodacore/core/http';
app.register(HttpPlugin);
API
Default Export
- HttpPlugin The main plugin class for integrating HTTP functionality with the Sodacore application.
Named Exports
Decorators:
Controller
(class decorator for HTTP controllers)Get
,Post
,Put
,Patch
,Delete
,Head
,Options
(method decorators for HTTP verbs)Middleware
(class decorator for HTTP middleware)Transform
(class/method decorator for response transformation)Body
,Cookies
,Headers
,Method
,Params
,Query
,Request
,Server
,Url
(parameter decorators for context injection)
Context & Services:
HttpContext
(base HTTP context)SseContext
(Server-Sent Events context)HttpService
(core HTTP service)SseConnectionsProvider
(manages SSE connections)
Utilities:
Utils
(helper functions for routing, cookies, responses, etc.)
Types:
IConfig
,IMiddleware
,IServerContext
,IControllerMetaMethodItem
(core HTTP types)
Notes
- This file is intended to be the single import point for all HTTP features in the Sodacore ecosystem.
- All exports are organized for clarity and ease of use, supporting both application and library development.
- Type exports ensure strong typing and IntelliSense support in TypeScript projects.