Skip to content

Projects-for-Fun/thefoodbook

Repository files navigation

The Food Book

Github Actions

Quality Gate Status

Running locally

Neo4j Desktop

Using Neo4j Desktop to create a db locally for the project (link).

Migration

Using golang-migrate. More info here.

Docker dependencies

Run make infra-up and run the project locally with webservice.

Need to set environment variables:

ENVIRONMENT=

SERVICE_NAME=
SERVICE_PORT=

LOG_LEVEL=
LOG_FORMAT=

DB_URI=
DB_USER=
DB_PASS=

JWT_KEY=

Run make infra-down or make cleanup in the end.

Run the service in Docker

Run make webservice and make cleanup in the end.

Clean code steps

make lint

make run-test

make run-integration

Endpoints

User related

Endpoints

Sign Up

  • URI: /sign-up

  • Method: POST

  • Headers: -

  • URL params: -

  • Query params: -

  • Data params:

    {
       "username": "username",
       "first_name": "First",
       "last_name": "Last",
       "email": "email@abc.com",
       "password": "password"
    }
    
  • Responses:

    • Success response:
      • Code: 201 Created
      • Content: -
    • Failure response:
      • Code: 400 Bad Request
      • Content: user already exists

Login

  • URI: /login

  • Method: POST

  • Headers:

    • X-Request-Id - correlation id as uuid
    • Authorization - Basic auth
  • URL params: -

  • Query params: -

  • Data params: -

  • Responses:

    • Success response:
      • Code: 200 OK
      • Content: -
      • Sets cookie.
    • Failure response:
      • Code: 400 Bad Request
      • Content: bad request
      • If Authorization Header is missing.
    • Failure response:
      • Code: 401 Unauthorized
      • Content: invalid username or password

Logout

  • URI: /logout

  • Method: POST

  • Headers:

    • X-Request-Id - correlation id as uuid
  • URL params: -

  • Query params: -

  • Data params: -

  • Responses:

    • Success response:
      • Code: 200 OK
      • Content: -
      • Removes cookie.

Refresh

  • URI: /auth/refresh

  • Method: POST

  • Headers:

    • X-Request-Id - correlation id as uuid
    • The cookie is required.
  • URL params: -

  • Query params: -

  • Data params: -

  • Responses:

    • Success response:
      • Code: 200 OK
      • Content: -
      • Updates cookie.
    • Failure response:
      • Code: 401 Unauthorized
      • Content: unauthorized
      • If the token is missing.