This project is a serverless application designed to manage customer data.
This endpoint enables clients to retrieve a list of customers.
- Method: GET
- Endpoint:
/api/customers
- Query Parameters:
name
: string (optional)email
: string (optional)telephone
: string (optional)
- Headers:
x-api-key
: YOUR_API_KEY
This endpoint allows clients to retrieve a list of customers near specified x, y geopoints.
- Method: GET
- Endpoint:
/api/customers/nearby
- Headers:
x-api-key
: YOUR_API_KEY
This endpoint enables clients to create a new customer.
- Method: POST
- Endpoint:
/api/customers
- Body:
name
: string (required)email
: string (required)telephone
: string (required)coordinate_y
: number (required)coordinate_x
: number (required)
- Headers:
x-api-key
: YOUR_API_KEY
-
Install Dependencies:
- Run
npm install
to install project dependencies.
- Run
-
Run Docker Compose:
- Execute
docker compose up db -d
to start the Postgres database.
- Execute
-
Set Environment Variables:
- Ensure that your
env.yml
file is properly configured.
- Ensure that your
-
Run Locally:
- Execute
sls offline
to run the project locally.
- Execute
-
Access Endpoints:
- Use the provided endpoints (e.g.,
/api/customers
) with the appropriate HTTP methods.
- Use the provided endpoints (e.g.,
Note: Make sure you have Serverless Framework installed (npm install -g serverless
) and configured with your cloud provider credentials.
![Database relations](https://private-user-images.githubusercontent.com/92169538/299830440-37f7f3fd-c3d0-4170-a9c3-3c83aa1a337d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzODk0MzEsIm5iZiI6MTczOTM4OTEzMSwicGF0aCI6Ii85MjE2OTUzOC8yOTk4MzA0NDAtMzdmN2YzZmQtYzNkMC00MTcwLWE5YzMtM2M4M2FhMWEzMzdkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDE5Mzg1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0MjFjMzEwOWIwMWYxYmRlZGZjYzJmODA5ZTAyYTViMTIxMjEwNjZhNmJkMWQyNWIxNmFjZjdmMDEwYjg0N2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Fhb7CX_WJcpYhdI-drWxW4al2AlzS0gxlOiwgiDYOfQ)
.
├── README.md
├── database
│ └── migrations
│ └── create_customers_table.sql
├── docker-compose.yml
├── env.yml
├── functions
│ └── api
│ ├── create-customer
│ │ ├── index.js
│ │ └── params-validator.js
│ ├── list-customers
│ │ └── index.js
│ └── nearby-customers
│ └── index.js
├── infra
│ ├── api-gateway
│ │ ├── auth-response.yml
│ │ └── cors.yml
│ └── lambda
│ ├── create-customer.yml
│ ├── list-customers.yml
│ └── nearby-customers.yml
├── lib
│ ├── calculate-distance.js
│ ├── database-client.js
│ └── responses.js
├── package-lock.json
├── package.json
├── repositories
│ └── customers-repository.js
├── scripts
│ └── start-local.sh
└── serverless.yml