0.4.3 • Published 3 years ago
@echemane/engines v0.4.3
Engines
Scaffolds NextJs API Route handlers in NestJs-like structure with react-query integration. Generate controllers, validation, DTOs and hooks.
Installation
- install globally in your system
npm i -g @echemane/engines- Install dependencies inside your current working directory
npm i next-api-decorators class-validator class-transformer path-to-regexp @tanstack/react-query- Setup your QueryClientProvider. See @tanstack/react-query docs
- Set
"experimentalDecorators": true,and"emitDecoratorMetadata": trueintsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
...
},
}Usage
engine create <name>
Generates engine which consist of the following; Data Transfer Objects (DTO) and REST Endpoints inside /page/api folder. See example below.
engine create productGenerate react-query hooks using --hooks or -h option
example:
engine create product -hengine guard <name>
Generates next-api-decorator guard. example:
engine guard authThis will generate AuthGuard inside src/engines/guards