Skip to content

I made this api by my own, as you can see there are two contributors, but I just din't swap from Anastasia account.

License

Notifications You must be signed in to change notification settings

KHYehor/PetStoreApi

Repository files navigation

PetStoreApi

This is realisation of pet store api, that I took from Swagger. As I count it takes 762 lines of code in src folder.

Architecture

I use the next architecture: Pet Store architecture.

As you can see, I have:

Protocol

In this layer as I planned I can try to change my transfer protocol from http to webscoket, for example. (You never know what customer wants).

protocol

Routing

Quite simple layer without a lot of logic, just route our requests to controllers. I have separated it to enteties: pet, store, user.

routing

Controller

Controller's task is to call service based on our request and answer something to client.

F.E. return data or return info that data was not found etc.

controller

Service

All buisness logic is placed here, here we can process our data, or call another external api service, count something, change our data. Validation is placed on this level.

service

Model

Model task is not so hard, you just need to take data from storage. It is separated during to entities.

model

Other tools

Middlewares

Yes, I have used some middlewares. They are used to mixin our request/responce context with our data. It is good to use for authentication, request parser, session id.

I used:

Crypto

I remember that we have to store our user's data in secure, so I also hash passwords and store them. If I want to compare passwords, I can't just decrypt it, I can only compare hashed one.

crypto

Validation

It is good that we can have validation on our frontend part, but it is also cool (you just have to) validate it on out server. I check validation on service layer.

validation

Config

I have separate folder to my project configurations, f.e. Redis Session store, MongoDB configs, I can also place my .env here.

config

Used Dependencies

And as you see, I have used next dependencies:

About

I made this api by my own, as you can see there are two contributors, but I just din't swap from Anastasia account.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published