Skip to content

Dooping/my-land-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Land - Backend

Description

Server side of My Land App

API

User

Path Method Description
/user POST Registers a new user
/user GET Logs the user in
/user DELETE Deletes a user

Register

POST /user

Endpoint used to register a new user. Requires a payload with the user's credentials

{
  "username": "david",
  "password": "password123"
}

Login

GET /user

Endpoint to log in the user through basic authentication.

Returns a JWT token in the header Access-Token. The token is valid for 30 days.

User Delete

DELETE /user

Endpoint to delete the current user.

Request must have a valid token

Authorization

All requests (besides login and register) must send a valid JWT token to the server. Either in the header Authorization as: Bearer {JWT-token}. Or in the parameter access_token.

Land

Entity:

Field Type Description
id number identifier
name string name of the land
description string description or state of the land
area number calculation of the area value
lat number latitude of the visualization point
lon number longitude of the visualization point
zoom number zoom of the camera in the visualization point
bearing number bearing of the camera in the visualization point
createdAt Date timestamp of the type's creation
modifiedAt Date timestamp of the type's last change
Path Method Parameters Description
/land GET Gets all lands from user
/land POST Creates a new land
/land PATCH Patches a land
/land GET id={landId} Fetches a single land
/land/{landId} GET Fetches a single land
/land/{landId} DELETE Deletes a land
/land/{landId}/object Land objects endpoints
/land/{landId}/objectType Object type endpoints
/land/{landId}/taskType Task type endpoints
/land/{landId}/task Task endpoints

Get lands

Fetches all the lands from the user

Request must have a valid token

Create land

Creates a new land

Request must have a valid token

Requires a payload with the new land

{
  "name": "example land name",
  "description": "some description",
  "area": 123.45,
  "lat": 12.34,
  "lon": 12.34,
  "zoom": 5,
  "bearing": 123.45, 
  "polygon": "some GeoJSON polygon"
}

returns the created land (payload + id)

Modify land

Changes either the description or the polygon and values associated with it.

Request must have a valid token

Requires one of the following payloads

{
  "id": 1,
  "description": "some description"
}
{
  "id": 1,
  "area": 123.45,
  "lat": 12.34,
  "lon": 12.34,
  "zoom": 5,
  "bearing": 123.45, 
  "polygon": "some GeoJSON polygon"
}

Get land

Fetches a single land

Request must have a valid token

The id can be in the path or as a parameter

Delete land

Deletes a single land

Request must have a valid token

Land Object

Entity:

Field Type Description
id number identifier
element string GeoJSON string describing the element
status string description of state of the object
typeId number identifier of the object type
Path Method Parameters Description
/land/{landId}/object GET Gets all objects from land
/land/{landId}/object POST Creates a new object
/land/{landId}/object DELETE type={id} Deletes all objects of a type
/land/{landId}/object/{id} PUT Edits an object
/land/{landId}/object/{id} DELETE Deletes an object

Get Land Objects

Fetches all objects from a land

Request must have a valid token

Create Land Object

Creates a new object in the given land

Request must have a valid token

Requires a payload with the new object

{
  "element": "Some GeoJSON",
  "status": "Some status",
  "typeId": 1
}

Modify Land Object

Edits the data of a land object

Request must have a valid token

Requires a payload with the new data

{
  "element": "Some GeoJSON",
  "status": "Some status",
  "typeId": 1
}

Delete Land Object

Deletes an existing object

Request must have a valid token

Requires an id as a path parameter

Delete Objects by Type

Deletes all objects of a given type

Request must have a valid token

Requires a type as a query parameter

Object type

Entity:

Field Type Description
id number identifier
name string name of the object type
color string hex color of the object
icon string icon representing the object type
createdAt Date timestamp of the type's creation
modifiedAt Date timestamp of the type's last change
Path Method Description
/land/{landId}/objectType GET Gets all object types
/land/{landId}/objectType POST Creates new object type(s)
/land/{landId}/objectType/{id} PUT Edits an object type
/land/{landId}/objectType/{id} DELETE Deletes an object type

Get Object Types

Fetches all object types for a land

Request must have a valid token

Create Object Type

Creates one or multiple object types in the given land

Request must have a valid token

Requires one of the following payloads

{
  "name": "example",
  "color": "#ffffff",
  "icon": "some icon name"
}
[
  {
    "name": "example",
    "color": "#ffffff",
    "icon": "some icon name"
  },
  "..."
]

Modify Object Type

Edits the data of an object type

Request must have a valid token

Requires an id as a path parameter

Requires a payload with the new object type

{
  "name": "example",
  "color": "#ffffff",
  "icon": "some icon name"
}

Delete Object Type

Deletes an existing object type

Request must have a valid token

Requires an id as a path parameter

Task Type

Entity:

Field Type Description
id number identifier
name string name of the task type
description string description of the task
Path Method Description
/land/{landId}/taskType GET Gets all task types from land
/land/{landId}/taskType POST Creates new task type(s)
/land/{landId}/taskType/{id} PUT Edits a task type
/land/{landId}/taskType/{id} DELETE Deletes a task type

Get Task Types

Fetches all task types for a land

Request must have a valid token

Create Task Type

Creates one or multiple task types in the given land

Request must have a valid token

Requires one of the following payloads

{
  "name": "Planting",
  "description": "planting seeds for some crops"
}
[
  {
    "name": "Planting",
    "description": "planting seeds for some crops"
  },
  "..."
]

Modify Task Type

Edits the data of a task type

Request must have a valid token

Requires an id as a path parameter

Requires a payload with the new task type

{
  "name": "Planting",
  "description": "planting seeds for some crops"
}

Delete Task Type

Deletes an existing task type

Request must have a valid token

Requires an id as a path parameter

Task

Entity:

Field Type Description
id number identifier
landId number identifier of the land
objectId number identifier of the object
taskTypeId number identifier of the task type
priority number priority of the task (1 to 5)
notes string any notes about the task
createdAt Date timestamp with creation time
modifiedAt Date timestamp with change time
completedAt Date/null timestamp with completion time
archivedAt Date/null timestamp with archiving time
Path Method Parameters Description
/task/{id} GET (optional) query=all\season\open Gets all user tasks
/land/{landId}/task GET (optional) objectId={id} Gets all land/object tasks
/land/{landId}/task POST Creates new task(s)
/task/{id} PUT Edits a task
/task/{id}/complete PUT Completes a task
/task/{id}/archive PUT Archives a task
/task/{id} DELETE Deletes a task

Get tasks

Fetches user tasks

The default value for the query parameter is all.

The possible values for the query parameter are:

  • all: fetches all user tasks, in any state
  • season: fetches only tasks that are not archived
  • open: fetches only tasks that are neither completed nor archived

Request must have a valid token

Get land tasks

Fetches all tasks from the land. If the parameter objectId is set, only fetches tasks for the specified object

Request must have a valid token

Create task

Creates one or multiple tasks in the given land

Request must have a valid token

Requires one of the following payloads

{
  "objectId": 1,
  "taskTypeId": 2,
  "priority": 3,
  "notes": "some notes about the task"
}
[
  {
    "objectId": 1,
    "taskTypeId": 2,
    "priority": 3,
    "notes": "some notes about the task"
  },
  "..."
]

Modify task

Edits the data of a task

Request must have a valid token

Requires an id as a path parameter

Requires a payload with the new task type

{
  "objectId": 1,
  "taskTypeId": 2,
  "priority": 3,
  "notes": "some notes about the task"
}

Complete task

Sets a task as completed

Request must have a valid token

Requires an id as a path parameter

Archive task

Sets a task as archived

Request must have a valid token

Requires an id as a path parameter

Delete task

Deletes a task

Request must have a valid token

Requires an id as a path parameter

Template

Object template entity

Field Type Description
default Map[string, List[ObjectType]] default object templates
fromLands List[List[ObjectType]] object templates in use by lands

Task template entity

Field Type Description
default Map[string, List[TaskType]] default task templates
fromLands List[List[TaskType]] task templates in use by lands
Path Method Parameters Permissions Description
/template/object GET locale User Gets all object templates for locale
/template/object POST Admin Creates a new object template
/template/object PUT Admin Edits an existing object template
/template/object DELETE locale, name Admin Deletes an object template
/template/task GET locale User Gets all task templates for locale
/template/task POST Admin Creates a new task template
/template/task PUT Admin Edits an existing task template
/template/task DELETE locale, name Admin Deletes a task template

Get Object Templates

Fetches all object templates for the provided locale

Request must have a valid token

Create Object Template

Creates a new object template

Requires a payload with the new data

{
  "locale": "en",
  "name": "some name",
  "objTypes": [
    {
      "name": "example",
      "color": "#ffffff",
      "icon": "some icon name"
    },
    "..."
  ]
}

Only admin users can make this request.

Modify Object Template

Edits the data of an object template.

Requires a payload with the new data

{
  "locale": "en",
  "name": "some name",
  "objTypes": [
    {
      "name": "example",
      "color": "#ffffff",
      "icon": "some icon name"
    },
    "..."
  ]
}

Only admin users can make this request.

Delete Object Template

Deletes an object template

Requires both locale and name as a query parameters

Only admin users can make this request.

Get Task Templates

Fetches all task templates for the provided locale

Request must have a valid token

Create Task Template

Creates a new task template

Requires a payload with the new data

{
  "locale": "en",
  "name": "some name",
  "taskTypes": [
    {
      "name": "example",
      "description": "some description"
    },
    "..."
  ]
}

Only admin users can make this request.

Modify Task Template

Edits the data of a task template.

Requires a payload with the new data

{
  "locale": "en",
  "name": "some name",
  "taskTypes": [
    {
      "name": "example",
      "description": "some description"
    },
    "..."
  ]
}

Only admin users can make this request.

Delete Task Template

Deletes a task template

Requires both locale and name as a query parameters

Only admin users can make this request.

About

Backend of MyLand App using Akka framework

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages