-
Notifications
You must be signed in to change notification settings - Fork 0
Express API
If you don't setted up, go back to home page and set up.
If something is not clear, create issue.
To start the server run:
npm run api-naYou will see:
📦Box master server is running at: http://localhost:939
To change the port modify the api.ts in api folder port variable (on line 12).
This endpoint returns an array of all the boxes in the database. You can also apply filters to the boxes by using query parameters. For example, to filter all boxes with the name "example", use the following endpoint:
GET /boxes?filter=name === 'example'
if you don't want to filter just use:
GET /boxes
This endpoint returns a single box with the specified ID.
This endpoint allows you to create, move, delete or edit a box. The :id parameter in the URL specifies the ID of the box to perform the action on. You need to provide a JSON payload in the request body with the following structure:
{
"action": "create" | "move" | "delete" | "edit",
"data": {
"attributes"?: object, // Only used when action is "create" or "edit"
"targetId"?: number | 'root' // Only used when action is "move"
}
}To create a box, set action to "create", and include an attributes object in the data field with the attributes for the new box. For example:
{
"action": "create",
"data": {
"attributes": {
"name": "New box",
"color": "blue"
}
}
}This will create a new box with the name "New box" and the color "blue" as a child of the box with the specified :id.
To move a box, set action to "move", and include a targetId field in the data field with the ID of the new parent box. If you want to move the box to the root level, set targetId to "root". For example:
{
"action": "move",
"data": {
"targetId": 3
}
}This will move the box with the specified :id to be a child of the box with ID 3.
To delete a box, set action to "delete". For example:
{
"action": "delete"
}This will delete the box with the specified :id.
To edit a box, set action to "edit", and include an attributes object in the data field with the new attributes for the box. For example:
{
"action": "edit",
"data": {
"attributes": {
"name": "Updated box",
"color": "red"
}
}
}This will update the name and color of the box with the specified :id.
This endpoint allows you to create a new box at the root level. You need to provide a JSON payload in the request body with the following structure:
{
"action": "create",
"data": {
"attributes": object
}
}Include an attributes object in the data field with the attributes for the new box. For example:
{
"action": "create",
"data": {
"attributes": {
"name": "New box",
"color": "blue"
}
}
}This will create a new box with the name "New box" and the color "blue" at the root level.