An open API service indexing awesome lists of open source software.

https://github.com/aya8merai/th-nestjs-e-commerce-api

A NestJS e-commerce backend API built with TypeScript and PostgreSQL, developed as a training project for the TECH HUB Full Stack Bootcamp.
https://github.com/aya8merai/th-nestjs-e-commerce-api

api backend-api database e-commerce-project nestjs postgresql

Last synced: 2 months ago
JSON representation

A NestJS e-commerce backend API built with TypeScript and PostgreSQL, developed as a training project for the TECH HUB Full Stack Bootcamp.

Awesome Lists containing this project

README

          


Nest Logo

[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.



NPM Version
Package License
NPM Downloads
CircleCI
Discord
Backers on Open Collective
Sponsors on Open Collective
Donate us
Support us
Follow us on Twitter


# NestJS E-commerce API

## Description

A scalable e-commerce backend API built with NestJS, TypeScript, and PostgreSQL. This project provides essential e-commerce functionality with role-based user management and product categorization.

## Features

- User Management with Role-Based Access Control (SUPER_ADMIN, ADMIN, CUSTOMER)
- Category Management
- Data Validation using class-validator
- PostgreSQL Integration with TypeORM
- Password Hashing with bcrypt
- Pagination Support
- Error Handling with Custom Exceptions

## Prerequisites

- Node.js
- PostgreSQL
- npm

## Project Setup

```bash
$ npm install
```

## Database Configuration

Update database credentials in `src/app.module.ts`:

```typescript
TypeOrmModule.forRoot({
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'your_username',
password: 'your_password',
database: 'your_database',
autoLoadEntities: true,
synchronize: true,
})
```

## Running the Project

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

## API Endpoints

### Users
- `POST /users` - Create user
- `GET /users` - Get all users (DESC order with pagination)
- `GET /users/:id` - Get one user
- `PUT /users/:id` - Update user's info
- `DELETE /users/:id` - Delete user

### Categories
- `POST /categories` - Create category
- `GET /categories` - Get all categories (ASC order with pagination)
- `GET /categories/:id` - Get one category
- `PUT /categories/:id` - Update category's info
- `DELETE /categories/:id` - Delete category