Skip to content

Latest commit

 

History

History
90 lines (83 loc) · 2.18 KB

readme.md

File metadata and controls

90 lines (83 loc) · 2.18 KB

Gymbeam case study

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.

Prerequisites

  • Typescript
  • Node.js
  • NPM

Installation

  1. Clone this repository:git clone <this-repo>
  2. Go to project directory: cd gymbeam_casestudy
  3. Install all required dependencies: npm install
  4. Create a .env file in the project root with required environment variables:
PORT=3000
GYMBEAM_API_KEY=YOUR_API_KEY

Running the application in development mode

To initiate the application in development mode, execute the following command:npm run start

Building and running the application for production

  1. Build the application:npm run build
  2. Start the production server:npm run prod (On port 3000, unless specified otherwise)

Running tests

You can execute unit tests using the following command: npm test

Use

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
}