Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/satnaing/haru-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/satnaing/haru-api
expressjs nodejs postgresql prisma typescript
Last synced: 2 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/satnaing/haru-api
- Owner: satnaing
- Created: 2021-09-26T14:44:30.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T11:38:43.000Z (almost 2 years ago)
- Last Synced: 2024-11-02T08:11:38.822Z (2 months ago)
- Topics: expressjs, nodejs, postgresql, prisma, typescript
- Language: TypeScript
- Homepage: https://satnaing.github.io/haru-api/
- Size: 2.12 MB
- Stars: 18
- Watchers: 3
- Forks: 10
- Open Issues: 13
-
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
![ts](https://badgen.net/badge/Built%20With/TypeScript/blue)
[![CircleCI](https://circleci.com/gh/satnaing/haru-api/tree/master.svg?style=shield)](https://circleci.com/gh/satnaing/haru-api/tree/master)
[![Heroku](https://pyheroku-badge.herokuapp.com/?app=angularjs-crypto&style=flat)](https://haru-fashion.herokuapp.com/)
[![Jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](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/satnaing/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
```