Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nawodyaishan/master-nest-js
This repository contains a Nest.js API project showcasing CRUD operations for managing events and associated person data. The API provides endpoints to create, retrieve, update, and delete events, along with their details.
https://github.com/nawodyaishan/master-nest-js
api nestjs nestjs-backend typescript
Last synced: about 2 months ago
JSON representation
This repository contains a Nest.js API project showcasing CRUD operations for managing events and associated person data. The API provides endpoints to create, retrieve, update, and delete events, along with their details.
- Host: GitHub
- URL: https://github.com/nawodyaishan/master-nest-js
- Owner: nawodyaishan
- Created: 2023-07-16T13:42:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-07T17:40:15.000Z (about 1 year ago)
- Last Synced: 2024-04-14T02:08:32.104Z (9 months ago)
- Topics: api, nestjs, nestjs-backend, typescript
- Language: TypeScript
- Homepage:
- Size: 410 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
A progressive Node.js framework for building efficient and scalable server-side applications.
## Description
**Features:**
- Create new events with person information.
- Retrieve events and associated details.
- Update event details by ID.
- Delete events by ID.
- API documentation for each endpoint.
- Unit testing with Jest.
- Logging with request tracking.**Technologies:**
- Nest.js framework
- TypeScript
- Jest testing framework## Installation
```bash
$ pnpm install
```## Running the app
```bash
# development
$ pnpm run start# watch mode
$ pnpm run start:dev# production mode
$ pnpm run start:prod
```## Test
```bash
# unit tests
$ pnpm run test# e2e tests
$ pnpm run test:e2e# test coverage
$ pnpm run test:cov
```## Events API Documentation
This API allows you to manage events and their associated information.
### Base URL
`http://localhost:3000`
### Endpoints
#### Get all events
- **URL**: `/events`
- **Method**: `GET`
- **Description**: Retrieve a list of all events.
- **Response**: An array of EventEntity objects.
- **Example**:
```http
GET /events
```
**Response**:
```json
[
{
"id": 1,
"personList": [...],
"when": "2023-08-27T12:34:56.789Z"
},
// ...
]
```#### Get event by ID
- **URL**: `/events/:id`
- **Method**: `GET`
- **Description**: Retrieve an event by its ID.
- **Parameters**:
- `id` (number): The ID of the event.
- **Response**: The EventEntity object associated with the provided ID.
- **Example**:
```http
GET /events/1
```
**Response**:
```json
{
"id": 1,
"personList": [...],
"when": "2023-08-27T12:34:56.789Z"
}
```#### Create a new event
- **URL**: `/events`
- **Method**: `POST`
- **Description**: Create a new event.
- **Request Body**: CreateEventDto object with person details.
- **Response**: A success message.
- **Example**:
```http
POST /events
Content-Type: application/json{
"name": "John Doe",
"age": 30,
"healthStatus": "Fine"
}
```
**Response**:
```json
"Event created for John Doe"
```#### Create multiple events
- **URL**: `/events/all`
- **Method**: `POST`
- **Description**: Create multiple events.
- **Request Body**: An array of CreateEventDto objects.
- **Response**: An array of names for the created events.
- **Example**:
```http
POST /events/all
Content-Type: application/json[
{
"name": "Alice",
"age": 25,
"healthStatus": "Bad"
},
{
"name": "Bob",
"age": 28,
"healthStatus": "Fine"
}
]
```
**Response**:
```json
["Event created for Alice", "Event created for Bob"]
```#### Update event by ID
- **URL**: `/events/:id`
- **Method**: `PATCH`
- **Description**: Update an event by its ID.
- **Parameters**:
- `id` (number): The ID of the event.
- **Request Body**: Updated EventEntity object.
- **Response**: The updated EventEntity object.
- **Example**:
```http
PATCH /events/1
Content-Type: application/json{
"id": 1,
"personList": [...],
"when": "2023-08-27T15:00:00.000Z"
}
```
**Response**:
```json
{
"id": 1,
"personList": [...],
"when": "2023-08-27T15:00:00.000Z"
}
```#### Remove event by ID
- **URL**: `/events/:id`
- **Method**: `DELETE`
- **Description**: Remove an event by its ID.
- **Parameters**:
- `id` (string): The ID of the event.
- **Response**: An object indicating the result of the removal operation.
- **Example**:
```http
DELETE /events/1
```
**Response**:
```json
{
"eventList": [...],
"message": "Event removed successfully"
}
```