Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

coco-help/backend

Repository files navigation

CoronaConnect backend

The backend that powers CoCo's hotline and front-end. It is developed using the serverless framework and is inteded to be deployed on AWS Lambda.

Endpoints

POST /register

Add a new helper to the database. After a successful request, the helper can be matched.

Example request

/register

Request body:

{
    "name": "Mark Test",
    "phone": "+4917612345678",
    "zip": "21037",
    "email": "[email protected]"
}

Response body:

{
    "message": "User created",
    "phone": "+4917612345678",
}

POST /login/{phone}

Send a login code to a helper's phone number.

Example request

/login/+4917612345678

Request body

None

Response body

{
    "message": "user_message_sent"
}

GET /verify/{phone}?code={code}

Verify that a phone number is accessible to a helper with a code sent by SMS.

Example request

/verify/+4917612345678?code=1234

Request body

None

Response body

{
    "message": "user_verified",
    "user": {
        "phone": "+4917612345678",
        "first_name": "Mark",
        "last_name": "Test"
    },
    "token": "eyJ0eXAiOiJLT1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODQ5MTI1NTksImV4cCI6MTU4NDkxMzQ1OSwicGhvbmUiOiIrNDkxNzY0MjA5MDgyMSJ9.ceaqi-SGNhX6AYEsypGty9Y1C3_Jwx46SQO2iGjek3I"
}

GET /helper/{phone}

Get data of a registered helper.

Example request

/helper/+4917612345678

Request headers

Key Value
Authorization eyJ0eXAiOiJLT1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODQ5MTI1NTksImV4cCI6MTU4NDkxMzQ1OSwicGhvbmUiOiIrNDkxNzY0MjA5MDgyMSJ9.ceaqi-SGNhX6AYEsypGty9Y1C3_Jwx46SQO2iGjek3I

Request body

None

Response body

{
    "phone": "+4917612345678",
    "first_name": "Mark",
    "last_name": "Test",
    "email": "[email protected]",
    "lon": 10.1329393,
    "lat": 53.4493502,
    "zip_code": "21037",
    "location_name": "Hamburg",
    "is_active": true,
    "verified": true
}

PUT /helper/{phone}

Update data of a registered helper.

Example request

/helper/+4917612345678

Request headers

Key Value
Authorization eyJ0eXAiOiJLT1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODQ5MTI1NTksImV4cCI6MTU4NDkxMzQ1OSwicGhvbmUiOiIrNDkxNzY0MjA5MDgyMSJ9.ceaqi-SGNhX6AYEsypGty9Y1C3_Jwx46SQO2iGjek3I

Request body

{
    "first_name": "Mark",
    "last_name": "Test",
    "email": "[email protected]",
    "zip_code": "21037",
    "is_active": false
}

Response body

{
    "phone": "+4917612345678",
    "first_name": "Mark",
    "last_name": "Test",
    "email": "[email protected]",
    "lon": 10.1329393,
    "lat": 53.4493502,
    "zip_code": "21037",
    "location_name": "Hamburg",
    "is_active": false,
    "verified": true
}

DELETE /helper/{phone}

Delete a registered helper.

Example request

/helper/+4917612345678

Request headers

Key Value
Authorization eyJ0eXAiOiJLT1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODQ5MTI1NTksImV4cCI6MTU4NDkxMzQ1OSwicGhvbmUiOiIrNDkxNzY0MjA5MDgyMSJ9.ceaqi-SGNhX6AYEsypGty9Y1C3_Jwx46SQO2iGjek3I

Request body

None

Response body

{
    "message": "deleted"
}

GET /phone?zip={zip}

Get the best matching helper for a zip code based on their distance to the zip code and the duration since they have last been called.

Example request

/phone?zip=21039

Request body

None

Response body

{
    "phone": "+4917612345678",
    "name": "Mark Test",
    "location": "Hamburg",
}

Contributing

Prerequisites

Setup

Install poetry

poetry install
poetry run task setup

Linting

poetry run task lint

Testing

poetry run task test

development deployment

make sure you have npm installed at a recent version.

npx serverless deploy --stage dev/<your_name>`

migrating database

look at the sql scripts in migrations/

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages