REST API for a CRUD employee management system, using serverless framework, aws and dynamodb
Clone the project with:
git clone https://github.com/g-asantos/aws-dynamodb-crud.git
Get in the project's path, then install the dependencies with:
yarn install
In case you wanna test the project locally, to start dynamodb run:
yarn dynamo:start
Then you can start the project with:
yarn dev
To deploy in AWS:
yarn deploy
Resource URL (public resource)
POST /createEmployee
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
name | string | Name of the employee | true |
age | string | Aage of the employee | true |
role | string | Role of the employee | true |
Returns message telling if employee was created or not.
Example Request
{
"name": "testname",
"age": "12",
"role": "manager"
}
Example Response
Response Code: 201 - CREATED
Body:
{
"message": "Employee created"
}
Resource URL (public resource)
GET /getAllEmployees
Parameters
No parameters required.
Returns a list with all employees registered in the system.
Example Request
No body necessary in the request.
Example Response
Response Code: 200 - OK
Body:
[
{
"name": "testnamez",
"id": "69f202ab-85a3-4a93-9272-5c3b0a131ba6",
"role": "manager",
"age": "12"
}
]
Resource URL (public resource)
GET /getEmployeeById/{id}
Query Parameters
Parameter | Type | Description | Required |
---|---|---|---|
id | string | id of the employee | true |
Returns employee information that matches id in the query params.
Example Request
No body necessary in the request.
Example Response
Response Code: 200 - OK
Body:
{
"name": "testname",
"id": "fd90e2e5-8073-4dad-a0ec-aa84552a564b",
"role": "manager",
"age": "12"
}
Resource URL (public resource)
PUT /updateEmployee/{id}
Query Parameters
Parameter | Type | Description | Required |
---|---|---|---|
id | string | id of the employee | true |
Returns updated employee information that matches id in the query params.
Example Request
{
"name": "thiswillwork",
"age": "1000",
"role": "unknown"
}
Example Response
Response Code: 200 - OK
Body:
{
"name": "thiswillwork",
"age": "1000",
"role": "unknown"
}
Resource URL (public resource)
DELETE /deleteEmployee/{id}
Query Parameters
Parameter | Type | Description | Required |
---|---|---|---|
id | string | id of the employee | true |
Returns message if the employee was deleted.
Example Request
No body necessary in the request.
Example Response
Response Code: 200 - OK
Body:
{
"message": "Employee with id 69f202ab-85a3-4a93-9272-5c3b0a131ba6 deleted"
}
- NodeJS
- Typescript
- Serverless
- AWS
- DynamoDB
Guilherme Azevedo dos Santos
- Github: @g-asantos
- Linkedin: @guilherme-azevedo-dos-santos-417a70159