npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@acrontum/oas-nestgen

v1.1.1

Published

Nestjs code generator for openapi.

Downloads

84

Readme

Nestgen

Nestjs code generator for openapi.

Early alhpa - docs subject to change.

Table of Contents

Install

Install from src (pre-release)

npm install
npm run build
npm pack
# from consumer project: npm i -D /path/to/oas-nestgen-0.0.1.tgz
# do the same for oas-typegen. you may need to install typegen first if there are issues with install

post-release:

npm install --save-dev @acrontum/oas-nestgen

Quickstart

npx oas-nestgen

Most up to date docs are in the cli help

npx oas-nestgen -h

Config

By default, nestgen looks for nestgen, nestgen.js, and nestgen.json. Config files extend the default config, and cli args overwrite both.

All config options are available from the cli with the exception of override functions - those must be configured in a config file.

Default config:

export const config: Config = {
  // -c, --config-file FILE             Config file name or path (default nestgen)
  configFile: 'nestgen',
  // -i, --typegen-path FILE            Path to typegen json (default typegen.json)
  typegenPath: 'typegen.json',
  // -s, --stub-service VALUE           If true, generate stubbed service methods (default true)
  stubService: true,

  // -d, --dry-run                      Just print changes, if any (default false)
  dryRun: false,

  // -a, --app-module-path PATH         Path to main app module (default ./src/app.module.ts)
  appModulePath: './src/app.module.ts',
  // -m, --modules-path PATH            Path to modules folder (default ./src/modules/)
  modulesPath: './src/modules/',
  // -o, --op-id-decorator-path PATH    OpId decorator file path (default ./src/common/decorators/op-id.decorator.ts)
  opIdDecoratorPath: './src/common/decorators/op-id.decorator.ts',

  // -O, --op-id-decorator-import NAME  OpId decorator import name (default src/common/decorators/op-id.decorator)
  opIdDecoratorImport: 'src/common/decorators/op-id.decorator',
  // -T, --types-import NAME            Typings import name (default src/types)
  typesImport: 'src/types',

  // -I, --ignored-op-ids NAME          Ignore changes for opId (can be invoked multiple times)
  ignoredOpIds: null,

  // codegen methods used to name params, add decorators, etc for when the defaults don't work for your project
  // rtfm for now src/parse-typegen exports all of these
  getMethodName,
  getReturnValue,
  namePathParams,
  nameQueryParams,
  nameHeadersParams,
  isDefaultProduces,
  extraDecorators,
  getMethodControllerName,
  getSubPath,
  getBodyParams,
  getControllerDecorators,
};

Example config override:

// my-custom-thingy.js

const { getMethodName: defaultGetMethodName } = require('oas-nestgen/dist/parse-typegen');

module.exports = {
  typegenPath: '/tmp/typegen.json',
  stubService: false,
  getMethodName(method/*: TypeGenMethod*/, basename/*: string*/) {
    const original = defaultGetMethodName(method, basename);

    if (original.indexOf('get') === 0) {
      const suffix = original.slice(3);

      return (/\}\/$/.test(method.path.name)) ? `show${suffix}` : `list${suffix}`;
    }

    return original;
  }
}
npx oas-nestgen -c ./my-custom-thingy.js --dry-run