
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
@lonestone/ncrud
Advanced tools
crud-generator
is a tool that generates automatically a module with its entity, repository, service, conversion service, controller and main CRUD API entrypoints.
Go in the directory where you want to write the module and simply start crud-generator
. The module's name and destination path will be prompted, and the files will be generated after confirmation.
Example of the output directory:
test-module
├── test-module.controller.ts
├── test-module.conversion.service.ts
├── test-module.entity.ts
├── test-module.module.ts
├── test-module.repository.ts
└── test-module.service.ts
It's possible to not be prompted the module's name and destination path by providing them as arguments and using the --auto
flag:
# Generate module "test-module" in current directory
npm start -- test-module . --auto
This package's source code contains a template
directory to generate the module's files at runtime.
If you want to add your own template, create a TypeScript file in this directory (with any name), and write the following inside:
import { Template } from '../template'
const tpl: Template = p => ({
fileName: 'genius.ts',
script: true,
source: `
console.log("I'm a genius!");
`
})
export default tpl
In the exported callback's returned object, fileName
is the name of the file to write and source
its content. The p
argument contains the callback's parameters, whose type is defined in src/cli/template.ts
.
Then, register the template in the exported object of src/cli/templates/index.ts
.
The related file will then be automatically generated at runtime.
The generated files are automatically formatted using ESLint and Prettier, by looking at the .eslintrc.json
and .prettierrc
files located in the destination path or one of its parent directories.
If no ESLint / Prettier configuration file is found, a warning is displayed to indicate no formatting will occur.
If a template needs to be removed or changed, it can be very simply edited in the dedicated file in src/cli/templates
.
New parameters can easily be added by extending the related type in src/cli/template.ts
.
They can also be renamed easily, as most IDEs support automatic refactoring, performing the renaming in all templates that already use this parameter.
FAQs
A simple CRUD generator for NestJS entities
We found that @lonestone/ncrud demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.