Welcome to my first backend project using various backend technologies and libraries!
- About the project
- Deploy
- Stack
- ER Diagram from SQL
- Clone
- Endpoints
- Future functionalities
- Contribution
- Web refferences
- Development
- Appreciation
- Contact
This project is about learning to use Express JS together with some other libraries such as bcrypt and jsonwebtoken on the way.
The main idea was creating a Database which logs in users/admins and Super Admins to a Tattoo Studio Web Page. To be fully functional users can create appointments, change them, choose what kind of service they want and so on. The same goes for admins(the tattoo artists) and we have one super admin which is the owner of the database and can manage everything if needed.
More functionalities coming veeeery soon! :)
Used technologies for the project:
- We have 4 entities in our Database created here. The strong among them is Roles (it can exist by itself), then we have Users which has many to one relation with roles. After this, we have Services which has One to many relation with our last entitiy (Appointments). Speaking of it - Appointments is the weekest of all entities, because it depends strongly on Users (because of the user_id) and Services(because of the service_id). More or less our database can be easily understood just by looking at the DDL schema posted here.
- Clone the repository from the url
$ npm install
(to get all the node packages)- Connect the cloned repo with our Database (if you dont have docker make a mysql container and run it on the wanted port such as:
docker run -d --name mysqlc -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -v mysql_data:/var/lib/mysql mysql
) - Change variables in .env with the PORT given from Docker
$ npm run migrations
$ npm run db:seed
$ npm run db:refresh
to execute everything from the beginning$ npm run dev
to run our server
Authentication π
-
REGISTER
POST http://localhost:4000/api/register
body:
{ "email": "[email protected]", "password": "123456789" }
-
LOGIN
POST http://localhost:4000/api/login
body:
{ "email": "[email protected]", "password": "123456789" }
Users π
-
GET ALL USERS (only admin)
GET http://localhost:4000/api/users
auth:
your token
-
GET USER PROFILE
GET http://localhost:4000/api/users/profile
auth:
your token
-
UPDATE USER PROFILE BY ID
PUT http://localhost:4000/api/profile/update
body:
{ "email": "[email protected]" }
auth:
your token
-
GET USER BY EMAIL (only admin)
GET http://localhost:4000/api/users/:email
body:
{ "email": "[email protected]" }
auth:
your token
-
DELETE USER BY ID (only admin)
DELETE http://localhost:4000/api/users/:id
body:
{ "id": 3 (the id of the user we want to delete) }
auth:
your token
-
CHANGE USER ROLE BY ID (only admin)
PUT http://localhost:4000/api/users/:id/role
auth:
your token
body:
{ "id" : 1 (this is the id of the user we will update) "role_id": 3 (the new role_id for our user goes here) }
Appointments βοΈ
-
CREATE APPOINTMENT
POST http://localhost:4000/api/appointments/create
body:
{ "appointment_date": "2024/01/01", "service_id": 2 }
auth:
your token
-
UPDATE USER APPOINTMENT BY ID
PUT http://localhost:4000/api/appointments/change
body:
{ "id": 3 (the id of the appointment to update) "appointment_date": "2024/07/20" (the new date) }
auth:
your token
-
GET USER APPIONTMENTS
GET http://localhost:4000/api/appointments/scheduled
auth:
your token
-
DELETE APPOINTMENT BY ID
DELETE http://localhost:4000/api/appointments/delete
auth:
your token
body:
{ "id": 3 (of the appointment you want to delete) }
-
GET APPOINTMENT BY ID
GET http://localhost:4000/api/appointments/:id
auth:
your token
body:
{ "id": 3 (the id of the appointment) }
Services πͺͺ
-
GET ALL SERVICES
GET http://localhost:4000/api/services
auth:
your token
-
CREATE SERVICE (only for admin)
POST http://localhost:4000/api/services
body:
{ "service_name": "name", "description": "what is the service about" }
auth:
your token
-
UPDATE SERVICE BY ID (only admin)
PUT http://localhost:4000/api/services/:id
body:
{ "id": 3 (the id of the service to be updated) "service_name": "new name" (new info) }
auth:
your token
-
DELETE SERVICE BY ID (only admin)
DELETE http://localhost:4000/api/services/:id
auth:
your token
body:
{ "id" : 3 }
Roles πͺͺ
-
GET ALL ROLES (only admin)
GET http://localhost:4000/api/roles
auth:
your token
-
CREATE ROLE (only admin)
POST http://localhost:4000/api/roles/create
body:
{ "name": "newRole" }
auth:
your token
-
UPDATE ROLE BY ID (only admin)
PUT http://localhost:4000/api/roles/update/:id
body:
{ "id": 8, "name": "newName" }
auth:
your token
-
DELETE ROLE BY ID (only admin)
PUT http://localhost:4000/api/roles/delete
body:
{ "id": 8 }
auth:
your token
β Add artists and relate them with appointments (still in progress)
β¬ Add user biometrics
β¬ Email and password validations
β¬ ...
Feel free to suggest an improvment or functionality to my project.
There are two ways of doing this:
- Opening an issue
- Creating a fork of the repository
- Creating a new branch
$ git checkout -b feature/yourUsername -feat
- Make a commit with your changes
$ git commit -m 'feat: this X thing'
- Make a push to the branch
$ git push origin feature/yourUsername -feat
- Opening a Pull Request
- Creating a new branch
To achieve my project I used data from the following sites:
- google.com
- nobleart.com
- ink.com
- ...
const developer = "yoanastamenova";
console.log("Developed by: " + developer);
Forever gratefull to GeeksHubs Academy for the oportunety to learn and grow on my career path. β€οΈ