Skip to content

sabey/ddd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Domain Driven Design

Requires: Postgres (edit RepositoryOpts.Addr struct in cmd/main.go and repo/pg_test.go) Build: cd cmd && go build && ./cmd Test: go vet ./... && go test ./... Address: http://localhost:8080/

API

POST /signup

Request:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"email": "jackson@juandefu.ca","password": "pass","firstName": "Jackson","lastName": "Sabey"}' \
  http://localhost:8080/signup

Body:

{
  "email": "jackson@juandefu.ca",
  "password": "pass",
  "firstName": "Jackson",
  "lastName": "Sabey"
}

Response:

{
  "token": "jwt-token" 
}

POST /login

Request:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"email": "jackson@juandefu.ca","password": "pass"}' \
  http://localhost:8080/login

Body:

{
  "email": "jackson@juandefu.ca",
  "password": "pass"
}

Response:

{
  "token": "jwt-token"
}

GET /users

Request:

curl --header "X-Authentication-Token: jwt-token" \
  http://localhost:8080/users

Response:

{
  "users": [
    {
      "email": "jackson@juandefu.ca",
      "firstName": "Jackson",
      "lastName": "Sabey"
    }
  ]
}

PUT /users

Request:

curl --header "X-Authentication-Token: jwt-token" --header "Content-Type: application/json" \
  --request PUT \
  --data '{"firstName": "JACKSON","lastName": "SABEY"}' \
  http://localhost:8080/users
{
  "firstName": "JACKSON",
  "lastName": "SABEY"
}

Response: none