Golang Notes REST API built on Clean Architecure
and Dependency Injection
principles. Authentication is implemented using JWT. Each user can add and access their own notes ONLY using a valid JSON Web Token generated on 0.0.0.0:8080/auth/sign-in
endpoint.
There is KODE.postman_collection.json
Postman collection file in root directory for API testing.
Run make run
or docker compose up --build
in root folder to apply all necessary migrations and start the project.
- 0.0.0.0:8080/auth/sign-up
=>
POST=>
Create new user - 0.0.0.0:8080/auth/sign-in
=>
POST=>
Log in to get access token
- 0.0.0.0:8080/api/v1/notes
=>
GET=>
Get all notes for user - 0.0.0.0:8080/api/v1/notes
=>
POST=>
Add note to user
- 0.0.0.0:8080/health
=>
GET=>
Check API connection
Request
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"your_name","password":"your_password"}' \
http://localhost:8080/auth/sign-up
Response
{"id":1}
Request
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"your_name","password":"your_password"}' \
http://localhost:8080/auth/sign-in
Response
{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjUwOTMxODIsImlhdCI6MTcyNTA4OTU4MiwiaWQiOjN9.T_PykTNRzx9ie2RjudyqrPYPuruAx3mo5ti2s5TZq0I"}
Request
curl --header "Content-Type: application/json" \
-H "Authorization: Bearer your_token" \
--request POST \
--data '{"content": "текст без ашибак"}' \
http://localhost:8080/api/v1/notes
Response
{"id":1}
Request
curl --header "Content-Type: application/json" \
-H "Authorization: Bearer your_token" \
--request GET \
http://localhost:8080/api/v1/notes
Response
[{"content":"текст без ошибок"}]