Skip to content

This app is responsable to generate boilerplate code to a NestJS REST API in Typescript

License

Notifications You must be signed in to change notification settings

Klynger/nest-rest-generator

Repository files navigation

Nest Logo

A code generator responsable to generate code for a NestJs application.

Package License

Summary

Description

This application implements a specification REST API to work together with the create-backend-app-core app.

Running things

Installation

$ yarn install

Running the app

# development
$ yarn start

# watch mode
$ yarn start:dev

# production mode
$ yarn start:prod

Test

# unit tests
$ yarn test

# e2e tests
$ yarn test:e2e

# test coverage
$ yarn test:cov

License

Nest Rest Generator is MIT licensed.

API description

Summary of the available routes that you can access.

Standard routes

Whoami

GET /whoami

Returns a JSON specifying what layers of a REST API for a Modal the app can generate and which type of API this is. Example of response:

{
  "apiType": "REST",
  "model": true,
  "module": true,
  "create": true,
  "update": true,
  "service": true,
  "controller": true,
  "repository": true
}

Specific routes

Generate controller

POST /controller

It gonna return the code of a controller file as a string. This is an example of a body to send:

{
  "implementedMethods": ["POST", "GET", "PUT"],
  "entityName": "User",
  "layerBellow": "service"
}

Generate service

POST /service

It gonna return the code of a service file as a string. This is an example of a body to send:

{
  "implementedMethods": ["POST", "GET", "PUT"],
  "entityName": "User",
  "layerBellow": null
}

Generate repository

POST /repository

It is going to return the code of a mocked repository. This is an example of a body to send:

{
  "implementedMethods": ["POST", "GET", "PUT", "DELETE"],
  "entityName": "Product",
}

Generate module

POST /module

{
	"entityName": "User",
	"controllers": ["User"],
	"services": ["User", "Product"],
	"repositories": ["User"],
	"modules": ["Product"]
}

Generate model

POST /model

It gonna return the code of a model file as a string. This is an example of a body to send:

{
  "entityName": "User",
  "attributes": [
    {
      "name": "id",
      "type": "string",
      "required": false
    },
    {
      "name": "name",
      "type": "string",
      "required": true
    },
    {
      "name": "pastNames",
      "type": {
        "typeName": "string[]",
        "importable": false
      },
      "required": false
    },
    {
      "name": "email",
      "type": "string",
      "required": true
    },
    {
      "name": "password",
      "type": "string",
      "required": true
    }
  ]
}

Generate create dto

It is going to return the code of a Create${entityName}Dto. This is an example of a body to send:

{
  "entityName": "User",
  "attributes": [
    {
      "name": "name",
      "type": "string",
      "required": true
    },
    {
      "name": "products",
      "type": "string[]",
      "required": false
    },
    {
      "name": "email",
      "type": "string",
      "required": true
    },
    {
      "name": "password",
      "type": "string",
      "required": true
    }
  ]
}

Generate update dto

It is going to return the code of a Update${entityName}Dto. This is an example of a body to send:

{
  "entityName": "User",
  "attributes": [
    {
      "name": "name",
      "type": "string",
      "required": true
    },
    {
      "name": "products",
      "type": "string[]",
      "required": false
    }
  ]
}

Generate static files

GET /static-files

It gonna return all static files necessary to create a project

About

This app is responsable to generate boilerplate code to a NestJS REST API in Typescript

Resources

License

Stars

Watchers

Forks

Packages

No packages published