https://github.com/mohnate/restful-api
A RESTful API built with NodeJS, Express, TypeScript. Prisma and PostgreSQL are used as database. This API is developed with Test Driven Development approach.
https://github.com/mohnate/restful-api
Last synced: 8 months ago
JSON representation
A RESTful API built with NodeJS, Express, TypeScript. Prisma and PostgreSQL are used as database. This API is developed with Test Driven Development approach.
- Host: GitHub
- URL: https://github.com/mohnate/restful-api
- Owner: mohnate
- Created: 2024-07-06T16:12:39.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-07T23:04:37.000Z (almost 2 years ago)
- Last Synced: 2025-03-27T09:42:36.104Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 249 KB
- Stars: 14
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Haru-Fashion API
RESTful API for Haru-Fashion e-commerce web application. Developed with NodeJS, Express, TypeScript, Prisma and PostgreSQL.
## Badges

[](https://circleci.com/gh/satnaing/haru-api/tree/master)
[](https://haru-fashion.herokuapp.com/)
[](https://github.com/facebook/jest)
[](https://github.com/prettier/prettier)
## Demo
[🚀 API Demo](https://haru-fashion.herokuapp.com/api/v1/categories)
[📖 API Docs](https://satnaing.github.io/haru-api/)
## Features
Here are some of the project's features
- CRUD Operations
- Authentication
- Authorization and RBAC
- Forgot/Reset Password
- Full-Text Search (for products)
## Tech Stack
**Backend:** Node, Express, TypeScript
**Database:** Prisma + PostgreSQL
**Testing:** Jest
**Containerization:** Docker
**CI/CD:** CircleCI
## Running Locally
Clone the project
```bash
git clone https://github.com/softking0503/haru-api.git
```
Go to the project directory
```bash
cd haru-api
```
Remove remote origin
```bash
git remote remove origin
```
Install dependencies
```bash
npm install
```
Add Environment Variables
_add the following environment variables to .env file. (some env var include example values)_
Click to expand!
- `NODE_ENV`
- `PORT`
- `POSTGRES_USER=testuser`
- `POSTGRES_PASSWORD=test123`
- `POSTGRES_DB=haru`
- `JWT_SECRET`
- `SMTP_HOST`
- `SMTP_PORT`
- `SMTP_USER`
- `SMTP_PASS`
- `FROM_NAME`
- `FROM_MAIL`
- `DATABASE_URL="postgresql://testuser:test123@postgres:5432/haru?schema=public"`
Migrate and seed database
```bash
npx prisma migrate dev --name init
```
```bash
npx prisma db seed
```
Can't reach database server Error ?
- _Change_ **@postgres** _to_ **@localhost** _in_ `DATABASE_URL` _inside .env **for a while**_
```bash
DATABASE_URL="postgresql://testuser:test123@postgres:5432/test_db?schema=public"
```
⬇️
```bash
DATABASE_URL="postgresql://testuser:test123@localhost:5432/test_db?schema=public"
```
Start the server
```bash
npm run dev
```
Stop the server
```bash
npm run dev:down
```
## Running Tests
To run tests, create a file called **.env.test** at the root of the project.
Then add the following environment variables.
`NODE_ENV=testing`
`DATABASE_URL="postgresql://prisma:prisma@localhost:5437/tests"`
Note! dotenv-cli must be installed golbally before running any test
```bash
sudo npm install -g dotenv-cli
```
Run the test
```bash
npm run test
```
Can't reach database server Error ?
- Run the test again
Stop the test
```bash
npm run test:down
```