Modular service to add posts written in golang
- Create an User
- Get a user using id
- Create a Post
- Get a post using id
- List all posts of a user
- Authentication without using JWT
- Make the server thread safe
- Add pagination to the list endpoint
- Add unit tests
- Clean Architecture
-
Pre-requisites:
- Go
-
Installation:
git clone https://github.com/techschneiderrr/appointy-task.git
cd posty
go mod download
-
Execution
-
direct
DB_URL=<encoded db url> go run api/main.go
loading env because godotenv package could not be used
-
Execution using shell
chmod +x runsample ./runsample
-
Run directly using docker!
docker run -p 8080:8080 rush3003/posty:latest
-
-
Testing
-
direct
DB_URL=<encoded db url> go test api/endpoint_test.go
-
Execution using shell
chmod +x runsample ./runsample
-
-
This project is built in
Clean Architecture
, it contains of two main modules, i.e. api and pkg. -
service
acts as usecase layer -
repository
as repository layer -
api
contains all the necessary route handlings and backend supporting services(i.e. receiving requests and forwarding to proper handlers) it contains packages:main
: contains main.go.presenter
: contains structs for response conditionshandlers
: contains all the necessaey handlers and linking with services, which in turn response using views.
-
pkg
contains the business logic divided into couple of packagespkg
: contains centralized errors.go file defining all the necessary errors which will thrown from backend and pkguser
: contains all the neccessary files for user business logicpost
: contains all the neccessary files for post business logicentities
: necessary middle man structs for holding participants and meetings data from db and so forth
-
utils
: contains all necessary files for helping functions
- Authentication
- Uses SHA256 hashing
- Every post made has to be authenticated with the password of the user (similar to the case with pushing to github on an https remote)
- packages
- made using only std packages and go-mongo driver
Visit the postman docs here