This exercise demonstrates skill proficiency in regards to the following requirement https://drive.google.com/file/d/1Gf-isBBtC4hZ7AhMfORJ9uuYC_YFCxyI/view?usp=sharing
- Express
- Node.js
- Typescript
- Docker
After cloning this repo git clone https://github.com/torsami77/clipboard_salary_exercise.git
, check into the root directory cd clipboard_salary_exercise
, and run docker compose up
to install all the dependencies, devDevpendencies, and run the API exposed on http://localhost:8080
.
Environnment variables and database has been by-passed to simplify the setup run to just "docker compose up" See dependencies, and "devDependencies" section in package.json file for list of all packages that would be installed
Use npm run docker-test
to run dockerized test or npm run test
to run test
npm run dev
: to run development modenpm run build
: to transpile build. see ./dist foldernpm start
: to run production modenpm test
: to run sample test on sample casesdocker compose up
: to spin up server in docker container
{
"statusCode": 200,
"message": "Welcome to clipboard_salary_exercise",
}
{
"errors": {
"username": "username should be alphabets, between 2 and 20 characters long",
"password": "Password should be at least 8 characters"
}
}
- Body
{
"username": "sami",
"password": "Pass10!?"
"confirm_password": "Pass10!?"
}
{
"statusCode": 201,
"message": "User created successfully",
"data": {
"id": 2,
"username": "torsami",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJ0b3JzYW1pIiwiaWF0IjoxNjcyMDY2NDQ5LCJleHAiOjE2NzIxNTI4NDl9.vjU0ECvz3zIuykgpkZo08fJfg-VXyuDEZt5FSI_Z9EU"
}
}
{
"errors": {
"username": "username should be alphabets, between 2 and 20 characters long",
"password": "Password should be at least 8 characters"
}
}
- Body
{
"username": "sami",
"password": "Pass10!?"
}
{
"statusCode": 200,
"message": "Successfully signed in",
"data": {
"id": 2,
"username": "torsami",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJ0b3JzYW1pIiwiaWF0IjoxNjcyMDY3NTUyLCJleHAiOjE2NzIxNTM5NTJ9.XpH_241IraDIeCapQOGUBST3lrkmdonmS1Ye3w2MM9k"
}
}
{
"statusCode": 401,
"message": "Access denied."
}
{
"errors": {
"name": "name should be alphabets, between 2 and 20 characters long",
"salary": "salary should be number",
"currency": "currency must be one of the following USD,EUR,INR",
"department": "Department is required",
"sub_department": "Provided sub_department must belong to department"
}
}
- Header
{
"authorization": "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJ0b3JzYW1pIiwiaWF0IjoxNjcyMDY3NTUyLCJleHAiOjE2NzIxNTM5NTJ9.XpH_241IraDIeCapQOGUBST3lrkmdonmS1Ye3w2MM9k"
}
- body
{
"name": "Samson",
"salary": 10000,
"currency": "USD" // ['USD', 'EUR', 'INR'],
"on_contract": true // not compulsory, but if provided value must be one of [true, false]
"department": "Engineering" // ['Engineering', 'Banking', 'Operations', 'Administration' ],
"sub_department": "Platform"
// Sub Departments List
// {
// department_name: "Engineering",
// sub_department: ["Platform"]
// },
// {
// department_name: "Banking",
// sub_department: ["Loan"]
// },
// {
// department_name: "Operations",
// sub_department: ["CustomerOnboarding"]
// },
// {
// department_name: "Administration",
// sub_department: ["Agriculture"]
// }
}
{
"statusCode": 201,
"message": "Request processed successfully",
"data": {
"id": 10,
"name": "Samson",
"salary": 10000,
"currency": "USD",
"on_contract": true,
"department": "Engineering",
"sub_department": "Platform"
}
}
{
"statusCode": 401,
"message": "Access denied."
}
- Header
{
"authorization": "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJ0b3JzYW1pIiwiaWF0IjoxNjcyMDY3NTUyLCJleHAiOjE2NzIxNTM5NTJ9.XpH_241IraDIeCapQOGUBST3lrkmdonmS1Ye3w2MM9k"
}
- URL
http://localhost: 8080/api/v1/salary_record/delete/3
{
"statusCode": 200,
"message": "Request processed successfully"
}
{
"statusCode": 401,
"message": "Access denied."
}
{
"statusCode": 200,
"message": "Request processed successfully",
"data": {
"max": 200000000,
"min": 30,
"mean": 22269454.444444444,
"category": "entire_summary_statistics"
}
}
{
"statusCode": 401,
"message": "Access denied."
}
{
"statusCode": 200,
"message": "Request processed successfully",
"data": {
"max": 110000,
"min": 10000,
"mean": 70000,
"category": "on_contract_summary_statistics"
}
}
{
"statusCode": 401,
"message": "Access denied."
}
{
"statusCode": 200,
"message": "Request processed successfully",
"data": [
{
"max": 200000000,
"min": 30,
"mean": 40053006,
"category": "Engineering_summary_statistics"
},
{
"max": 90000,
"min": 90000,
"mean": 90000,
"category": "Banking_summary_statistics"
},
{
"max": 70000,
"min": 30,
"mean": 35015,
"category": "Operations_summary_statistics"
},
{
"max": 30,
"min": 30,
"mean": 30,
"category": "Administration_summary_statistics"
}
]
}
{
"statusCode": 401,
"message": "Access denied."
}
{
"statusCode": 200,
"message": "Request processed successfully",
"data": [
{
"department_name": "Engineering",
"sub_departments": [
{
"max": 200000000,
"min": 30,
"mean": 40053006,
"category": "Platform_sub_department_summary_statistics"
}
]
},
{
"department_name": "Banking",
"sub_departments": [
{
"max": 90000,
"min": 90000,
"mean": 90000,
"category": "Loan_sub_department_summary_statistics"
}
]
},
{
"department_name": "Operations",
"sub_departments": [
{
"max": 70000,
"min": 30,
"mean": 35015,
"category": "CustomerOnboarding_sub_department_summary_statistics"
}
]
},
{
"department_name": "Administration",
"sub_departments": [
{
"max": 30,
"min": 30,
"mean": 30,
"category": "Agriculture_sub_department_summary_statistics"
}
]
}
]
}