@trapi/metadata 📚

This package is responsible for generating metadata information by analyzing TypeScript REST decorators (self defined or third-party libraries).
The metadata can than be used for generating a documentation according to the OpenAPI Specification or to create route schema/handling for libraries like: express, koa, etc.
Inspect the CHANGELOG.md
in the repository for breaking changes.
Table of Contents
Installation
npm install --save @trapi/metadata
Configuration
Metadata
The metadata configuration object (Top-Level) is the main configuration object of this library
and can be defined according the following type scheme:
import {
CacheOptions,
DecoratorConfig
} from "@trapi/metadata";
export type EntryPointOptions = {
cwd: string,
pattern: string
};
export type EntryPoint = string |
string[] |
EntryPointOptions |
EntryPointOptions[];
export interface Options {
entryPoint: EntryPoint;
ignore?: string[];
allow?: string[],
cache?: string | boolean | Partial<CacheOptions>;
decorators?: DecoratorConfig[],
preset?: string;
}
Limitations
At the moment only the following TypeScript UtilityTypes are supported:
- NonNullable
- Omit
- Partial
- Readonly
- Record
- Required
- Pick
Usage
import {
generateMetadata,
Metadata
} from "@trapi/metadata";
import path from "node:path";
import process from "node:process";
const metadata : Metadata = await generateMetadata({
entryPoint: ['src/controllers/**/*.ts'],
ignore: ['**/node_modules/**'],
cache: true,
preset: '@trapi/preset-routup'
});
console.log(metadata);
Structure
coming soon
License
Made with 💚
Published under MIT License.