This project have simple CRUD implementation, but a great and scalable architecture. Before each commit and push, tests are automatically running to guarantee the project security
You should have docker instaled You should have firebase account and a real time data base running
- Clone the project:
git clone https://github.com/Luryy/Onyma-Appointments.git
cd Onyma-Appointments
- Create a .env file:
COPY the .env.example and fill the fields
- Create a docker image
docker build . -t onyma-appointments
- Finally Create your container
docker run -d --name onyma-appointments -p 3333:3333 onyma-appointments
The aplicacation have 5 routes:
GET /appointments
- To list all of your appointments.GET /appointments/:id
- To list an appointment by it id.POST /appointments
- To create a new appointment - and in return the appointment created.POST /appointments/:id
- To edit an existent appointment by it id - and in return the appointment updated. It's possibly to update only one params.DELETE /appointments/:id
- To delete an appointment by it id.
POST params:
{
"address": "MaceiΓ³",
"patientName": "Lucas",
"dateTime": "22h40",
"state": "scheduled"
}
Here is the project structure:
.
βββ src
β βββ modules
β β βββ appointments
β β βββ container
β β β βββ index.ts
β β βββ dtos
β β β βββ IAppointmentDTO.ts
β β β βββ ICreateAppointmentDTO.ts
β β β βββ IUpdateAppointmentDTO.ts
β β βββ infra
β β β βββ firebase
β β β β βββ models
β β β β β βββ Appointment.ts
β β β β βββ repositories
β β β β βββ AppointmentsRepository.ts
β β β βββ http
β β β βββ controllers
β β β β βββ AppointmentsController.ts
β β β βββ routes
β β β βββ appointments.routes.ts
β β βββ repositories
β β β βββ fakes
β β β β βββ FakeAppointmentsRepository.ts
β β β βββ IAppointmentsRepository.ts
β β βββ useCases
β β βββ CreateAppointment
β β β βββ CreateAppointmentUseCase.spec.ts
β β β βββ CreateAppointmentUseCase.ts
β β βββ DeleteAppointment
β β β βββ DeleteAppointmentUseCase.spec.ts
β β β βββ DeleteAppointmentUseCase.ts
β β βββ ListAppointments
β β β βββ ListAppointmentsUseCase.spec.ts
β β β βββ ListAppointmentUseCase.ts
β β βββ ShowAppointment
β β β βββ ShowAppointmentUseCase.spec.ts
β β β βββ ShowAppointmentUseCase.ts
β β βββ UpdateAppointment
β β βββ UpdateAppointmentUseCase.spec.ts
β β βββ UpdateAppointmentUseCase.ts
β βββ shared
β βββ container
β β βββ index.ts
β βββ helpers
β β βββ types
β β βββ PartialRequireOne.ts
β βββ infra
β βββ firebase
β β βββ index.ts
β βββ http
β βββ app.ts
β βββ middlewares
β β βββ rateLimiter.ts
β βββ routes
β β βββ index.ts
β βββ server.ts
βββ babel.config.js
βββ Dockerfile
βββ heroku.yml
βββ jest.config.js
βββ LICENSE
βββ package.json
βββ prettier.config.js
βββ README.md
βββ tsconfig.json
βββ yarn.lock
This project is based at Domain-driven design.
At folder models is where your domains should be, and the commons configurations should be at the shared folder.
- container - where you register dependency injection
- dtos - define transfer objects
- infra - external services - should use interfaces and dependency injection for decoupling purpose
- repositories - repository interface and fake (for tests)
- useCases - where shoud be the business rule of your application | remember to create unit tests!
To a better understanding you should open the files and see yours responsabilities.
π€ Lucas Yuri
- Github: Luryy
- LinkedIn: Lucas Yuri
Copyright Β© 2020 Lucas Yuri. This project is MIT licensed.