Registry / devops / typescript-rest-api-generator

typescript-rest-api-generator

JSON →
library1.0.9jsnpmunverified

A CLI tool (v1.0.9, last updated in 2022) called Rest API Generator (RAG) that scaffolds TypeScript-based REST APIs using Express, TypeORM, MySQL, and Awilix for dependency injection. It generates a clean, layered architecture (Controller → Service → Repository → Database) with built-in support for JWT authentication and bcrypt password hashing. Unlike generic project starters, it provides code generation commands (rag create controller/service/repository/model) and a full DI container setup out of the box. Note: development appears to have stalled, with no recent commits or releases.

npm install typescript-rest-api-generator
INSTALL
IMPORT
SIG · TYPESCRIPT-REST-AP
T
typescript-rest-api-generator
devopsjavascriptv1.0.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rag
npx rag create new <project-name>
npm run rag
rag is the CLI binary, not a module; use npx or global install
ExampleRepository
export class ExampleRepository { ... }
module.exports = class ExampleRepository { ... }
Use ES6 class syntax, not CommonJS exports
ExampleService
export class ExampleService { constructor({ exampleRepository }) { ... } }
class ExampleService { constructor(exampleRepository) { ... } }
Awilix expects constructor parameters as a single destructured object matching registration names
ExampleController
export class ExampleController { constructor({ exampleService }) { ... } }
class ExampleController { constructor(exampleService) { ... } }
Same as service; DI container injects via destructured parameter

Installs the CLI globally, scaffolds a new project named 'my-api', and starts the dev server.

npm install -g typescript-rest-api-generator rag create new my-api cd my-api # After scaffolding, run the development server npm run dev
Debug
Known issues
deprecatedPackage has not been updated since 2022; may have compatibility issues with newer Node.js and TypeScript versions.
fix
Consider using a more actively maintained alternative like fastify-cli or nestjs/cli.
affects: =1.0.9
breakingGenerated code depends on TypeORM 0.2.x; migration to TypeORM 0.3+ may break due to API changes (e.g., getRepository vs dataSource.getRepository).
fix
Manually update TypeORM import patterns or use a fork that supports latest TypeORM.
affects: >=1.0.0
gotchaCLI installs dependencies via npm install which may fail if npm registry is unreachable or permissions are insufficient.
fix
Run `rag create new project-name` with appropriate npm permissions or use `--skip-install` if available.
affects: >=1.0.0
gotchaThe generated code uses mysql2 as default database driver; switching to another database (e.g., PostgreSQL) requires manual configuration changes.
fix
Modify ormconfig.json and install the appropriate database driver before running migrations.
affects: >=1.0.0
deprecatedTypeORM's `getRepository` method is deprecated in favor of `dataSource.getRepository` in newer versions; generated code may produce deprecation warnings.
fix
Update repository files to use the new pattern: const repository = dataSource.getRepository(Entity);
affects: >=1.0.0
Errors
Common errors & fixes
rag: command not found
Global npm binary not in PATH
fix
Ensure npm global bin directory is in PATH, or use `npx typescript-rest-api-generator create new ...`
Error: Cannot find module 'typeorm'
Dependencies not installed during scaffolding
fix
Run `npm install` inside the generated project directory
TypeError: Class constructor ExampleService cannot be invoked without 'new'
Awilix container expects a factory function, not a class directly
fix
Register services with `asClass` in the DI container, e.g., `container.register({ exampleService: asClass(ExampleService) })`
Cannot use decorators in TypeScript without 'experimentalDecorators'
tsconfig.json missing experimentalDecorators option
fix
Add `"experimentalDecorators": true` to tsconfig.json compilerOptions
Upgrade
Version history
1.0.9latest on npm
Audit
Dependencies
expressrequiredHTTP server framework
typeormrequiredORM for database access
mysql2requiredMySQL database driver
awilixrequiredDependency injection container
awilix-expressrequiredExpress integration for Awilix
jsonwebtokenrequiredJWT authentication
bcryptrequiredPassword hashing
reflect-metadatarequiredRequired by TypeORM decorators
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources