@williamfernandes/regen
v0.3.0
Published
Generate the skeleton (service, repository and factory) for an application resource.
Downloads
1
Maintainers
Readme
Regen
Generate the skeleton (service, repository and factory) for an application resource.
regen scaffold -r product
// src/repository/product.repository.ts
export default class ProductRepository {
constructor() {}
async create(data: any) {
return Promise.reject("Method not implemented.");
}
async update(id: number, data: any) {
return Promise.reject("Method not implemented.");
}
async delete(id: number) {
return Promise.reject("Method not implemented.");
}
async read(id: number) {
return Promise.reject("Method not implemented.");
}
}
// src/service/product.service.ts
export default class ProductRepository {
constructor() {}
async create(data: any) {
return Promise.reject("Method not implemented.");
}
async update(id: number, data: any) {
return Promise.reject("Method not implemented.");
}
async delete(id: number) {
return Promise.reject("Method not implemented.");
}
async read(id: number) {
return Promise.reject("Method not implemented.");
}
}
// src/factory/product.factory.ts
import ProductRepository from "../repository/product.repository";
import ProductService from "../service/product.service";
export default class ProductFactory {
static getInstance() {
return new ProductService(new ProductRepository());
}
}
Requirements
In order to use regen
, you need to have Node.js (>=20
) installed on your machine.
Installation
If you want to install regen
as a development dependency to a project, cd
into the project and run
npm install -D @williamfernandes/regen
Usage
regen scaffold
Scaffold a new resource in your project.
Options:
--help Show help [boolean]
--version Show version number [boolean]
-r, --resource The name of the resource to scaffold [array] [required]
Examples:
scaffold -r product Scaffold a project with a single "product" domain
scaffold -r product -r user Scaffold a project with two domains: "product" an
d "user"