Skip to content

gfw-api/gfw-area

Repository files navigation

GFW Area API

Build Status Test Coverage

Dependencies

The GFW User API microservice is built using Node.js, and can be executed either natively or using Docker, each of which has its own set of requirements.

Native execution requires:

Execution using Docker requires:

Dependencies on other Microservices:

Getting started

Start by cloning the repository from github to your execution environment

git clone https://github.com/resource-watch/gfw-area.git && cd gfw-area

After that, follow one of the instructions below:

Using native execution

1 - Set up your environment variables. See dev.env.sample for a list of variables you should set, which are described in detail in this section of the documentation. Native execution will NOT load the dev.env file content, so you need to use another way to define those values

2 - Install node dependencies using yarn:

yarn

3 - Start the application server:

yarn start

The endpoints provided by this microservice should now be available through the webserver's URL.

Using Docker

1 - Create and complete your dev.env file with your configuration. The meaning of the variables is available in this section. You can find an example dev.env.sample file in the project root.

2 - Execute the following command to run the application:

./area.sh develop

The endpoints provided by this microservice should now be available through the webserver's URL.

Testing

There are two ways to run the included tests:

Using native execution

Follow the instruction above for setting up the runtime environment for native execution, then run:

yarn test

Using Docker

Follow the instruction above for setting up the runtime environment for Docker execution, then run:

./area.sh test

Configuration

Environment variables

  • PORT => TCP port in which the service will run
  • NODE_PATH => relative path to the source code. Should be app/src
  • MICROSERVICE_TOKEN =>
  • MONGO_PORT_27017_TCP_ADDR => IP/Address of the MongoDB server

You can optionally set other variables, see this file for an extended list.

Quick Overview

Area Entity


name: <String>, required
geostore: <String>
wdpaid: <Number>
createdAt: <Date>
userId: <String>
datasets: JSON.stringify([{
    slug: 'viirs',
    name: 'VIIRS',
    active: false,
    startDate: '20150101',
    endDate: '20170101'
}])

geostore or wdpaid are required. Only one.

CRUD Area


GET: /area -> Return all areas of the user logged
GET: /area/:id -> Return area with the same id. Check if the area is owned of the logged user
POST: /area -> Create an area and associate to the user. With body:

#form data
name: "my-area"
geostore: "2a23af251"

PATCH: /area/:id -> Update the area with the same id. Check if the area is owned of the logged user
DELETE: /area/:id -> Delete the area with the same id. Check if the area is owned of the logged user

[]: https://travis-ci.com/gfw-api/gfw-area

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages