It's a simple application written in Express with TypeScript that includes a single endpoint designed for sorting items in a warehouse according to their distance from the source. This ensures the most optimal gathering of specified items from the warehouse.
- Typescript
- Node.js
- NPM
- Clone this repository:
git clone <this-repo>
- Go to project directory:
cd gymbeam_casestudy
- Install all required dependencies:
npm install
- Create a
.env
file in the project root with required environment variables:
PORT=3000
GYMBEAM_API_KEY=YOUR_API_KEY
To initiate the application in development mode, execute the following command:npm run start
- Build the application:
npm run build
- Start the production server:
npm run prod
(On port3000
, unless specified otherwise)
You can execute unit tests using the following command: npm test
Application will create a POST endpoint at /api/warehouse/get-picking-order
, which expects a body in the following JSON format:
{
"products": [
"product-2",
"product-1",
"product-4",
"product-3"
],
"originPoint": {
"x": 0,
"y": 0,
"z": 0
}
}
The originPoint is not required. If not provided, the default value of {x: 0, y: 0, z: 0}
will be used, as shown in the example above.
For effective testing, you can use the CURL command provided below:
curl --request POST \
--url http://localhost:3000/api/warehouse/get-picking-order \
--header 'Content-Type: application/json' \
--data '{
"products": [
"product-2",
"product-1",
"product-4",
"product-3"
],
"originPoint": {
"x": 0,
"y": 0,
"z": 0
}
}'
Expected result: (Valid on 12.07.2023 11:23 - can change in the future)
{
"pickingOrder": [
{
"productId": "product-1",
"positionId": "position-31"
},
{
"productId": "product-4",
"positionId": "position-120"
},
{
"productId": "product-2",
"positionId": "position-241"
},
{
"productId": "product-3",
"positionId": "position-124"
}
],
"distance": 27
}