Skip to content

AnastasiaKosovets/ak-fsd-backend-dentalClinic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to my backend app

Fourth project in Geekshubs Academy FSD 04-2023

'imagen-db'

Contet: đź“ť
  1. Target
  2. About the project
  3. Stack
  4. Diagrama
  5. Installation
  6. Project structure
  7. Endpoints
  8. Contributions
  9. License
  10. Webgrafia
  11. Acknowledgments
  12. Contacts

Target

This project required a functional API connected to a database with at least a one-to-many and a many-to-many relationship. Putting into practice the knowledge acquired mainly with sequelize - express.

About the project

This project consisted of creating a web application for a dental clinic, in which we would have several features such as:

  • user registration
  • login access
  • access to user profile
  • profile modification according to permissions
  • access to appointments and their modification
  • view own appointments (user, doctor)
  • view all appointments according to permissions

I was investigating several apps of this style to see the structure and to be able to better apply all the points and functionalities.

Stack

Technologies that has been used:

Diagrama BD

'imagen-db'

Installation

  1. Clone the project on your computer with git bash: $git clone 'url-repository'
  2. Install all dependencies with the following command: $ npm i
  3. Conectamos nuestro repositorio con la base de datos
  4. Start the server with: $ npm run dev
  5. Connect the repository with the database with the following commands: $ npx sequelize-cli db:create $ npx sequelize-cli db:migrate $ npx sequelize-cli db:seed:all
  6. Run this file in postman to enable access to the endpoints of the project Run in Postman

Project structure

I have based on the creation of basic CRUD. This project has the following structure:

  • Index.js: This is the main file.

  • Config.

    • Config.json: This file is created automatically by sequelize and it managed the configuration to connect to the database.
  • Middlewares: This file manages common services, such as authentication through use of tokens to access API restricted zones.

    • isAdmin
    • isDoctor
    • verifyToken
  • db.js: Shows the configuration that must have into .env file that must be created for the application to work. PORT = PORT JWT_SECRET = SECRET

  • Router.js: This file manages the different paths that the application can have. He creado varias rutas para poder gestionar mejor la informacion

  • Views:

    • appointmentRoutes.js: In this file we manage the endpoints that point to that route.
    • authRoutes.js: In this file we manage the endpoints pointing to that path.
    • treatmentRoutes.js: In this file we manage the path /treatments and the endpoints pointing to that path.
    • usersRoutes.js: In this file we manage the endpoints that point to that path.
  • Controllers: There are controllers for each of the established routes.

Endpoints

Endpoints
  • AUTH
    • REGISTER

        POST http://localhost:9000/auth/register
      

      body:

          {
              "email": "[email protected]",
              "password": "1234",
              "firstName": "Prueba"
              "lastName": "Prueba"
              "document": "123456789"
              "address": "prueba"
              "telefonNumber": "123456789"
              "collegialNumber": "123456789"
          }
    • LOGIN

        POST http://localhost:9000/auth/login  
      

      body:

          {
              "email": "[email protected]",
              "password": "1234"
          }
  • Create appointment:

    • Create appointment only for the logged in user through postman with POST option.

        POST:   http://localhost:9000/app
      

      body:

      {
          "doctor_id": "1",
          "patient_id": "1",
          "treatment_id": "3",
          "price": 10,
          "date": "2023-06-12"
      }
  • Cancel appointment by Admin:

    • CANCEL petition to delete any user appointments currently in the database.

        DELETE:   http://localhost:9000/appointments/:id
      

    You must indicate in the url the ID number of the appointment.

  • Check all appointments by Admin:

    • GET a list of all users' appointments.

        GET:   http://localhost:9000/appointments
      
  • Check all appointments by Doctor:

    • GET a list of all appointments.

        GET:   http://localhost:9000/appointments/doctorsAppointment
      
  • Check personal appointment by User:

    • GET a list of all appointments.

        GET:   http://localhost:9000/appointments/myAppointment
      
  • Check profile:

    • GET petition to see the user´s own profile.

        GET:   http://localhost:9000/users/profile
      
  • Update profile:

    • We update profile from the logged user.

        PUT:   http://localhost:9000/users/:id
      

      body:

      {
          "email": "[email protected]",
          "password": "1234",
          "firstName": "prueba",
          "lastName": "prueba",
          "document": "123456789",
          "address": "c/tal, Valencia",
          "telefonNumber": "123456789",
          "collegialNumber": "123456789",
          "role_id": 2
      }
  • Check all user profiles by Admin:

    • GET petition to see the user´s profile, if you are logged like an Admin, will show all the information about the users.

        GET:   http://localhost:9000/users
      
  • Check all user profiles by Doctor:

    • GET petition to see the user´s profile, if you are logged like a doctor, will show only the relevant information about the users.

        GET:   http://localhost:9000/users/patients
      
  • Delete treatment by Admin:

          DELETE:   http://localhost:9000/treatments/:id
    

    You must indicate in the url the ID number of the treatment.

  • Update user by Admin:

    • Update profile from the logged Admin.

        POST:   http://localhost:9000/users/:id
      

      body:

      {
          "email":"",
          "password":"",
          "firstName":"",
          "lastName":"",
          "document":"",
          "address":"",
          "telefonNumber":"",
          "collegialNumber":"",
          "role_id":""
      }
  • Delete user by Admin:

    • Delete user and all info by Admin.

        POST:   http://localhost:9000/users/:id
      

      is required user_id.

  • Create treatment:

    • Create treatment by Admin

        POST:   http://localhost:9000/treatments
      

      body:

      {
          "treatmentName": "",
          "description": "",
          "price": 10,
      }

Contributions

Suggestions and contributions are always welcome.

You can do this in two ways:

  1. Opening an issue
  2. Create a fork of the repository
    • Create a new branch
      $ git checkout -b feature/nombreUsuario-mejora
      
    • Make a commit with your changes
      $ git commit -m 'feat: mejora tal parte'
      
    • Make push to the branch
      $ git push origin feature/nombreUsuario-mejora
      
    • Open a Pull Request

Licencia

This project is belonging to license Creative Commons Legal Code.

Webgrafia:

To achieve my goal I have collected information from:

Acknowledgments:

I thank my teachers for their time dedicated to this project:

  • Dani

  • Jose

  • David

  • Mara

Contacts

About

Fourth Project in GeeksHubs Academy, API for manage Dental Clinic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published