{"id":16464760,"url":"https://github.com/ekramasif/nestjs_crud","last_synced_at":"2026-04-13T06:37:14.835Z","repository":{"id":236736299,"uuid":"793055996","full_name":"ekramasif/NestJS_CRUD","owner":"ekramasif","description":"This is a NestJS-based application that provides CRUD operations, authentication using JSON Web Tokens (JWT), managing entity relationships, and integration with a third-party API.","archived":false,"fork":false,"pushed_at":"2024-05-03T18:39:04.000Z","size":274,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T17:45:32.368Z","etag":null,"topics":["api","authentication","crud","entity-relationships","jwt","mysql","nestjs","nestjs-backend","nestjs-crud","nodejs","onetomany"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ekramasif.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-28T09:56:26.000Z","updated_at":"2025-04-17T07:15:59.000Z","dependencies_parsed_at":"2024-11-11T20:40:40.821Z","dependency_job_id":"fc374f92-ebbf-4a46-9ef2-6365d08ec392","html_url":"https://github.com/ekramasif/NestJS_CRUD","commit_stats":null,"previous_names":["ekramasif/nestjs_crud"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ekramasif/NestJS_CRUD","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekramasif%2FNestJS_CRUD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekramasif%2FNestJS_CRUD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekramasif%2FNestJS_CRUD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekramasif%2FNestJS_CRUD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ekramasif","download_url":"https://codeload.github.com/ekramasif/NestJS_CRUD/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekramasif%2FNestJS_CRUD/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266193880,"owners_count":23890876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","authentication","crud","entity-relationships","jwt","mysql","nestjs","nestjs-backend","nestjs-crud","nodejs","onetomany"],"created_at":"2024-10-11T11:29:42.703Z","updated_at":"2026-04-13T06:37:14.790Z","avatar_url":"https://github.com/ekramasif.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cb\u003eNestJS CRUD\u003c/b\u003e\n\u003c/p\u003e\n\n\nThis is a NestJS-based application that provides CRUD operations, authentication using JSON Web Tokens (JWT), managing entity relationships, and integration with a third-party API.\n\n### Prerequisites\n\n- Node.js\n- MySQL\n\n### Installation\n\n1. **Clone the repository:**\n\n    ```bash\n    git clone https://github.com/ekramasif/NestJS_CRUD.git\n    ```\n\n2. **Navigate to the project directory:**\n\n    ```bash\n    cd NestJS_CRUD\n    ```\n\n3. **Install dependencies:**\n\n    ```bash\n    npm install\n    ```\n\n4. **Set up the database:**\n   \n   - Create a new database in MySQL.\n   - Update the `databaseConfig` in `src/config/database.config.ts` with your MySQL credentials and database name.\n\n5. **Start the application:**\n\n    ```bash\n    npm run start:dev\n    ```\n\n    The application should now be running at [http://localhost:3000](http://localhost:3000).\n\n### API Endpoints\n\n#### Users\n\n- **GET /users:** Get a list of all users.\n- **GET /users/:id:** Get a specific user by ID.\n- **POST /users:** Create a new user.\n- **PUT /users/:id:** Update an existing user.\n- **DELETE /users/:id:** Delete a user.\n\n#### Authentication\n\n- **POST /auth/register:** Register a new user.\n  - Request Body:\n    - `name`: User's name\n    - `email`: User's email address\n    - `password`: User's password\n- **POST /auth/login:** Authenticate a user and obtain a JWT token.\n  - Request Body:\n    - `email`: User's email address\n    - `password`: User's password\n- **GET /auth/get-user:** Get user details using JWT token stored in cookies.\n- **POST /auth/logout:** Log out the user and clear the JWT token stored in cookies.\n\n#### Bookings\n\n- **GET /bookings:** Get a list of all bookings.\n- **GET /bookings/:id:** Get a specific booking by ID.\n- **POST /bookings:** Create a new booking.\n- **PUT /bookings/:id:** Update an existing booking.\n- **DELETE /bookings/:id:** Delete a booking.\n\n#### Passengers\n\n- **GET /passengers:** Get a list of all passengers.\n- **GET /passengers/:id:** Get a specific passenger by ID.\n- **POST /passengers:** Create a new passenger.\n- **PUT /passengers/:id:** Update an existing passenger.\n- **DELETE /passengers/:id:** Delete a passenger.\n\n#### Tickets\n\n- **GET /tickets:** Get a list of all tickets.\n- **GET /tickets/:id:** Get a specific ticket by ID.\n- **POST /tickets:** Create a new ticket.\n- **PUT /tickets/:id:** Update an existing ticket.\n- **DELETE /tickets/:id:** Delete a ticket.\n\n#### Third-Party API Integration\n\n- **GET /comments:** Fetch data from a third-party API.\n\n### Authentication\n\nThe application uses JWT for authentication. To register a new user, send a POST request to `/auth/register` with the user's name, email, and password in the request body. To authenticate a user, send a POST request to `/auth/login` with the user's email and password. Upon successful authentication, the server will respond with a JWT token, which should be included in the `Authorization` header for authenticated routes.\n\nTo access authenticated routes, such as getting user details (`/auth/get-user`), the JWT token must be stored in cookies. The user's details can be retrieved by sending a GET request to `/auth/get-user`, which will validate the JWT token stored in cookies and return the user's details.\n\nTo log out the user, send a POST request to `/auth/logout`, which will clear the JWT token stored in cookies and log the user out.\n\n### Third-Party API Integration\n\nThe application integrates with a third-party API to fetch data. The specific API endpoint is configurable in the `CommentsService`. By default, it fetches data from [https://jsonplaceholder.typicode.com/comments](https://jsonplaceholder.typicode.com/comments).\n\n### Database\n\nThe application uses TypeORM with MySQL as the database. The database connection is configured in `src/config/database.config.ts`. User data is stored in the `user` table.\n\n#### Entity Relationships\n\n![ER Diagram](nestdiagram.png)\n\n- **Booking:** Each booking belongs to a user and can have multiple passengers and tickets associated with it.\n- **Passenger:** Each passenger belongs to a booking.\n- **Ticket:** Each ticket belongs to a booking.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekramasif%2Fnestjs_crud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekramasif%2Fnestjs_crud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekramasif%2Fnestjs_crud/lists"}