Skip to content

@nestjsx/crud starter repository for RESTful APIs running on Fastify

Notifications You must be signed in to change notification settings

josephgodwinkimani/nestjsx-crud-starter

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Simple Blog API (CRUD users, users CRUD posts)

nestjsx-crud TypeORM Fastify REST API

Nest TypeScript starter repository with NestJs CRUD for RESTful APIs and Fastify.

Installation

$ pnpm install

Running the app

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod

Test

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov

API Endpoints

nestjsx/crud Crud() decorator generates the following API endpoints:

Get many resources

GET /users
GET /posts

Result: array of resources | pagination object with data, Status Codes: 200

Get one resource

GET /users/:id
GET /posts/:id

Request Params: :id - some resource field (slug), Result: resource object | error object, Status Codes: 200 | 404

Create one resource

POST /users
POST /posts

Request Body: resource object | resource object with nested (relational) resources, Result: created resource object | error object, Status Codes: 201 | 400

Update one resource

PATCH /users/:id
PATCH /posts/:id

Request Params: :id - some resource field (slug), Request Body: resource object (or partial) | resource object with nested (relational) resources (or partial), Result: updated partial resource object | error object, Status codes: 200 | 400 | 404

Delete one resource

DELETE /users/:id
DELETE /posts/:id

Request Params: :id - some resource field (slug), Result: empty | resource object | error object Status codes: 200 | 404

License

This repo is MIT licensed.

Related Projects