New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@trapi/metadata

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trapi/metadata

Generate REST-API metadata scheme from TypeScript Decorators.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
186
increased by4.49%
Maintainers
1
Weekly downloads
 
Created
Source

@trapi/metadata 📚

main codecov Known Vulnerabilities npm version

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 {
    /**
     * The entry point to your API.
     */
    entryPoint: EntryPoint;
    
    /**
     * Directory to ignore during TypeScript files scan.
     * Default: []
     */
    ignore?: string[];

    /**
     * Directory to allow during TypeScript files scan.
     * Default: []
     */
    allow?: string[],
    
    /**
     * Directory to store and cache metadata files.
     * Default: false
     */
    cache?: string | boolean | Partial<CacheOptions>;
    
    /**
     * Manual decorator properties configuration.
     */
    decorators?: DecoratorConfig[],

    /**
     * Load a specific preset configuration.
     */
    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);
// {controllers: [], referenceTypes: {}}

Structure

coming soon

License

Made with 💚

Published under MIT License.

Keywords

FAQs

Package last updated on 17 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc