@injitools/core
v0.2.1
Published
Core of the Inji framework: declarative router, DTO/Zod validation, OpenAPI generation and error handling. No database dependency.
Maintainers
Readme
@injitools/core
Core of the Inji framework: a declarative router with DTO/Zod validation, OpenAPI 3.1 generation, middleware wiring and an error hierarchy. No database dependency.
Part of the Inji monorepo.
Install
npm install @injitools/coreRequires experimentalDecorators + emitDecoratorMetadata in your tsconfig.json.
Usage
import {Router, Get, Response, InjiRouter} from "@injitools/core";
@Router("hello")
class HelloApi {
@Get()
@Response(200, String)
index() { return "Hello"; }
}
const router = new InjiRouter([HelloApi]);
app.use(router.toExpressRouter()); // Express router
router.toOpenApi(); // OpenAPI 3.1 specEntry points
@injitools/core— router,RequestDto/ResponseDtoand validation decorators, error middleware,buildOpenApiDocument(router → OpenAPI 3.1 doc), andcreateApiClient/createFetchClient(an inter-server client between backends).@injitools/core/codegen—emitSchema(router → generatedschema.gen.tsTS interfaces for frontends). A separate subpath (usesnode:fs) so runtime servers don't pull in the generator. Needs only ORM metadata — run it offline via TypeORM'sbuildMetadatas(), no DB connection.@injitools/core/runtime—env,Config,loadEnv, environment helpers.@injitools/core/lifecycle—makeProcess, graceful shutdown.
See the monorepo README for the full picture.
License
MIT
