nestjs-modscan
v1.0.0
Published
A CLI and library for extracting and diffing NestJS controller endpoints from TypeScript projects.
Readme
nestjs-modscan
A CLI and library for extracting and diffing NestJS controller endpoints from TypeScript projects.
Features
- Extracts endpoints from controllers listed in the
controllersarray of NestJS modules using static analysis (ts-morph) - Compares (diffs) two sets of extracted endpoints
- Usable as a CLI tool or as a Node.js package
CLI Usage
Installation
npm install -g nestjs-modscan
# or use with npx:
npx nestjs-modscan ...Commands
Extract Endpoints
Extracts endpoints from a NestJS project and outputs them as JSON.
nestjs-modscan extract --tsconfig path/to/tsconfig.json --output endpoints.json--tsconfig(optional): Path to yourtsconfig.json(defaults to./tsconfig.json)--output(optional): Output file (defaults to stdout)
Diff Endpoints
Compares two endpoint JSON files and prints the diff.
nestjs-modscan diff old.json new.jsonLibrary Usage
Install as a dependency:
npm install nestjs-modscanExample
import { extractControllersFromProject } from 'nestjs-modscan'
// Extract endpoints from a project
const endpoints = extractControllersFromProject('./tsconfig.json')
console.log(endpoints)API
extractControllersFromProject(tsConfigFilePath: string): Endpoint[]
Extracts endpoints from all controllers listed in the controllers array of NestJS modules.
diffEndpointSets(oldEndpoints: Endpoint[], newEndpoints: Endpoint[]): DiffResult
Compares two sets of endpoints and returns the diff.
Contributing
Contributions are welcome! To get started:
- Fork this repository and clone your fork.
- Install dependencies with
yarnornpm install. - Make your changes in a feature branch.
- Add or update tests as needed.
- Open a pull request with a clear description of your changes.
Please ensure your code follows the existing style or be prepared to convince me :D
License
MIT
