1.1.9 • Published 5 months ago

crud-generator-ts v1.1.9

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

CRUD Generator TS

A CRUD generator for TypeScript applications using Express and TypeORM.

Installation

npm install -g crud-generator-ts

Usage

generate-crud <resource-name>

Example

generate-crud userType

This command will generate:

  • Entity (user-type.ts)
  • Controller (user-type-controller.ts)
  • Repository (user-type-repository.ts)
  • Routes (user-type.routes.ts)

Recommended Directory Structure

your-project
├── src/
│   ├── infra/
│   │   ├── database/
│   │   │   └── main.ts
│   │   └── entity/
│   │       ├── index.ts
│   │       └── user-type.ts
│   ├── controllers/
│   │   └── user-type-controller.ts
│   ├── repositories/
│   │   └── user-type-repository.ts
│   └── routes/
│       ├── index.ts
│       └── user-type.routes.ts
├── package.json
└── tsconfig.json

Prerequisites

Your application must have:

  • Configured TypeORM
  • Configured Express
  • Configured TypeScript
  • A database configuration file (src/infra/database/main.ts)
  • An authentication middleware (isAuthenticated)

Generated Files

Entity

  • Base class with common fields (ID, created/updated user and timestamp)
  • Decoradores TypeORM
  • Schema configurável via variável de ambiente

Controller

  • Basic CRUD with methods:
    • getAll()
    • getById()
    • create()
    • update()
    • delete()
  • TSOA decorators for documentation

Repository

  • Methods for database operations:
    • findAll()
    • findById()
    • create()
    • update()
    • deleteById()

Routes

  • REST endpoints:
    • GET /
    • GET /:id
    • POST /
    • PUT /:id
    • DELETE /:id
1.1.1

5 months ago

1.1.0

5 months ago

1.1.9

5 months ago

1.1.8

5 months ago

1.0.9

5 months ago

1.1.7

5 months ago

1.1.6

5 months ago

1.1.5

5 months ago

1.1.3

5 months ago

1.1.2

5 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago