Skip to content

MihaiLupoiu/services

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Services

Build

Repository of services

Services List

User

Service for storing user related information

Run Docker Compose: To run the service, inside /scripts there is a docker compose file.

docker-compose up

Build binary:

cd src
make build

To run tests it requires Postgresql to be started:

cd src
make tests

Endpoints:

  • Create User: http://localhost:8080/user/add Creates a user and does not require authentication
curl -s -X POST -H "Content-Type: application/json" -d "{ \"firstname\": \"Jhon\", \"lastname\": \"Donals\", \"email\": \"jd@fake.com\",\"password\": \"1234\"}" http://localhost:8080/user/add
  • Login: http://localhost:8080/login Login using an email an valid password and generates authentication JWT TOKEN. Required in further operations.
TOKEN=$(curl -s -X POST -H 'Accept: application/json' -H "Content-Type: application/json" -d "{ \"email\": \"jd@fake.com\",\"password\": \"1234\"}" http://localhost:8080/login | sed -e 's/^"//' -e 's/"$//' )
  • GetUser: http://localhost:8080/user/{id} Get user data. If authenticated, it will return user id data, but only his data.
curl -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://localhost:8080/user/1
  • UpdateUser: http://localhost:8080/user/{id} Update user data information if authenticated.
curl -s -X POST -H "Content-Type: application/json" 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" -d "{ \"firstname\": \"Jhon\", \"lastname\": \"Smith\", \"email\": \"js@gmail.com\",\"password\": \"1234\"}" http://localhost:8080/user/1
  • DeleteUser: http://localhost:8080/user/{id} Delete user if authenticated.
curl -i -X DELETE -H "Content-Type: application/json" 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://localhost:8080/user/1

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published