You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.0 KiB
3.0 KiB
Shelf Project
An online storefront to showcase products. Users is able to browse an index of all products, see the specifics of a single product, and add products to an order that they can view in a cart page.
Pre-requisite
- Add a
.env
file in /Shelf folder with the following :
POSTGRES_HOST=127.0.0.1
POSTGRES_DB=shelf
POSTGRES_TEST_DB="shelf_test"
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
ENV=dev
BCRYPT_PASSWORD=speak-friend-and-enter
SALT_ROUNDS=10
TOKEN_SECRET=alohomora123!
TOKEN_SECRET_TEST=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoxLCJmaXJzdG5hbWUiOiJKb2huIiwibGFzdG5hbWUiOiJEb2UiLCJ1c2VybmFtZSI6InRlc3QiLCJwYXNzd29yZF9kaWdlc3QiOiIkMmIkMTAkeXNkTHQuUjVqdjFJdHVzTk5NMGJNLlU0RkZvbmJRYUV2VFBsVnFhQWJqSkV3NTdzTEZwVGEifSwiaWF0IjoxNjUzMjUzODIxfQ.rdC42gcdhzAwnwwVJxmhBLVK5tvf2zONG3UcHLU6xE0`
- Inside shelf folder mount the container:
docker compose up
- Create shelf_test database with the following commands:
--
docker exec -it shelf-postgres-1 /bin/bash
--psql -U postgres
--CREATE DATABASE shelf_test
Installation
- Install packages dependencies:
npm install
- Run tests:
npm run test
- Run the database:
npm run up
- Launch the application:
npm run start
Note : If needed you can reset the tables by closing the app and running the following commands:
npm run down
npm run up
Availaible endpoints
-
Products :
HTTP Verb Endpoint CRUD Get /products
Index Get /products/:id
Read Post /products
Create ( Token ) Put /products/:id
Update ( Token ) Delete /products/:id
Delete ( Token ) -
Users :
HTTP Verb Endpoint CRUD Get /users
,Index ( Token ) Get /users/:id
Read ( Token ) Post /users
Create Put /users/auth
Authenticate ( Token ) Put /users/:id
Update ( Token ) Delete /users/:id
Delete ( Token ) -
Orders
HTTP Verb Endpoint CRUD Get /orders
,Index ( Token ) Get /orders/:id
Read Post /orders
Create Post /orders/:id/products
Create ( Token ) Delete /orders/:id/products
Delete ( Token )
Built with
- Typescript
- Node
- Express
- Dotenv
- Docker
- Postgres
- Db-migrate
- Jsonwebtoken
- Jasmine
- Supertest
Author
Anis Benziane.