Scaffolds NextJs API Route handlers in NestJs-like structure with react-query integration. Generate controllers, validation, DTOs and hooks.
npm install @echemane/engines
npm i -g @echemane/engines
`
2. Install dependencies inside your current working directory
`
npm i next-api-decorators class-validator class-transformer path-to-regexp @tanstack/react-query
`
3. Setup your QueryClientProvider. See [@tanstack/react-query docs]()
4. Set "experimentalDecorators": true, and "emitDecoratorMetadata": true in tsconfig.json
`json
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
...
},
}
`
Usage
$3
Generates engine which consist of the following; Data Transfer Objects (DTO) and REST Endpoints inside /page/api folder. See example below.
`
engine create product
`
$3
example:
`
engine create product -h
`
$3
Generates next-api-decorator guard.
example:
`
engine guard auth
`
This will generate AuthGuard` inside src/engines/guards