Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/said-alisic/clothesstore_kea

Node.js server connected with a MySQL database through sequelize for Software Development Bachelor's semester one databases course mandatory assignment
https://github.com/said-alisic/clothesstore_kea

express mysql-database nodejs sequelize-orm

Last synced: 12 days ago
JSON representation

Node.js server connected with a MySQL database through sequelize for Software Development Bachelor's semester one databases course mandatory assignment

Awesome Lists containing this project

README

        

# Documentation

Welcome to the ClothesStore_KEA documentation. The application is not finished yet and is being gradually updated.

## Setup instructions

**Prerequisites**
- npm
- node.js
- mysql
- create .env file under server directory

**.env file contents**
- DB={name}
- DB_HOST={host} (e.g., localhost)
- DB_USER={user} (e.g., admin or root, etc.)
- DB_PASS={password}
- DB_DIALECT={database_dialect} (e.g., mysql or postgres)
- PORT={port} (e.g. we use 8080)

**Creating database**
1. 001_create_clothes_store_db.sql: Contains all scripts to create new database and add a new user to it
2. 002_create_clothes_store_triggers.sql: Contains scripts to create triggers for database tables
3. 003_populate_clothes_store_db.sql: Contains scripts to populate the database with data
4. 004_reset_clothes_store_db.sql: Contains scripts to delete db content and repopulate it

**Running the app**
1. Navigate to the folder server folder
2. Run `npm install` to install all dependencies
3. Run `npm run start` to start the backend API server
4. Navigate to http://localhost:8080 for the api (e.g. http://localhost:8080/api/users to GET all users)
5. Navigate to http://localhost:4200 for the client application ( Not yet implemented )

**Testing the API**
1. Navigate to http://localhost:8080/api-docs
2. Use the Swagger API development tool to test the API CRUD endpoints

**Sign in - things to note**\
To sign in after the database was populated use credentials:
- sign in as ADMIN with rights to do all operations (role ID 1)\
email: [email protected]
password: JaJiPass
- sign in as EMPLOYEE (role ID 2)\
email: [email protected]
password: BoBaPass
- sign in as CUSTOMER (role ID 3)\
email: [email protected]
password: JaJo
- To sign up, add a new user with Swagger or Postman API testing application

**Data to use with Postman to sign up as a CUSTOMER**
1. POST a new user to the API route http://localhost:8080/api/users
- {
"role_id": 3,
"first_name": "new",
"last_name": "user",
"email": "[email protected]",
"password": "newpass"
}

2. POST sign in credentials to sign in with the new user at http://localhost:8080/api/users/signin
- {
"email": "[email protected]",
"password": "newpass"
}