|
1 |
| -openSenseMap-API |
2 |
| -================ |
3 |
| - |
4 |
| -[](https://gitter.im/sensebox/openSenseMap-API?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
5 |
| -This is the back-end for [openSenseMap](https://opensensemap.org). |
6 |
| - |
7 |
| -openSenseMap is part of the [senseBox](https://sensebox.de) project. |
8 |
| -To get more information about openSenseMap and senseBox visit the before mentioned links or have a look at this [video](https://www.youtube.com/watch?v=uTOWYa42_rI). |
9 |
| - |
10 |
| -Originally, this API has been built as part the bachelor thesis of @mpfeil at the ifgi (Institute for Geoinformatics, WWU Münster). |
11 |
| - |
12 |
| -### Technologies |
13 |
| - |
14 |
| -* [node.js] |
15 |
| -* [MongoDB] |
16 |
| - |
17 |
| -### Development |
18 |
| - |
19 |
| -#### Node.js |
20 |
| -It is assumed that you have installed node.js Version 6 LTS. Install dependencies with [yarn](https://yarnpkg.com/) |
21 |
| -``` |
22 |
| -yarn install |
23 |
| -``` |
24 |
| - |
25 |
| -There are several config keys in `config/index.js`. These can also be configured through environment keys. Just prefix your environment keys with `OSEM_` to be read by the api. |
26 |
| - |
27 |
| -#### Database |
28 |
| -The API needs a running MongoDB instance with a `OSeM-api` database and credentials. |
29 |
| - |
30 |
| -The best way to run the database for development is to use the supplied `docker-compose.yml` and run |
31 |
| -``` |
32 |
| -docker-compose up -d db |
33 |
| -``` |
34 |
| - |
35 |
| -### `require()` openSenseMap-API for other projects |
36 |
| - |
37 |
| -You can require several parts of the API in other projects. |
38 |
| - |
39 |
| -Install it as dependency |
40 |
| -``` |
41 |
| -# for specific branch/commit/tag append #<branch/commit/tag> |
42 |
| -yarn add git://github.com/sensebox/openSenseMap-API.git |
43 |
| -``` |
44 |
| - |
45 |
| -This allows you to use parts like models and decoding in your own project. See `index.js`. |
46 |
| - |
47 |
| -### Create the JSDoc pages |
48 |
| - |
49 |
| -To create the documentation you need [apidocjs](http://apidocjs.com/) and run: |
50 |
| -``` |
51 |
| -apidoc -e node_modules/ |
52 |
| -``` |
53 |
| - |
54 |
| -### Running Tests |
55 |
| -You can run the tests in containers using docker and docker-compose. |
| 1 | +# openSenseMap API |
| 2 | + |
| 3 | +[openSenseMap] is part of the [senseBox] project. To get more information about openSenseMap and senseBox visit the before mentioned links or have a look at this [video](https://www.youtube.com/watch?v=uTOWYa42_rI), read the [API docs](https://docs.opensensemap.org) or the [openSenseMap](https://osem.books.sensebox.de/) chapter in our [books](https://books.sensebox.de/). |
| 4 | + |
| 5 | +## Organization |
| 6 | + |
| 7 | +This repository is a monorepo for the packages |
| 8 | + |
| 9 | +- [](https://www.npmjs.com/package/@sensebox/opensensemap-api-models) [@sensebox/opensensemap-api-models](models) The data models and database connection of openSenseMap. |
| 10 | +- [](https://www.npmjs.com/package/@sensebox/opensensemap-api) [@sensebox/opensensemap-api](api) The REST API used by [https://opensensemap.org](https://opensensemap.org) running at [https://api.opensensemap.org](https://api.opensensemap.org). |
| 11 | + |
| 12 | +### Directories |
| 13 | +- root directory |
| 14 | + - not published on NPM |
| 15 | + - is used to build a Docker container image |
| 16 | + - contains tests (run with `./run-tests`) |
| 17 | +- [api](api) directory |
| 18 | + - NPM [@sensebox/opensensemap-api](https://www.npmjs.com/package/@sensebox/opensensemap-api) |
| 19 | + - [Changelog](api/CHANGELOG.md) |
| 20 | + - should not appear as dependency of other packages |
| 21 | +- [models](models) directory |
| 22 | + - NPM [@sensebox/opensensemap-api-models](https://www.npmjs.com/package/@sensebox/opensensemap-api-models) |
| 23 | + - [Changelog](models/CHANGELOG.md) |
| 24 | + - `require('@sensebox/opensensemap-api-models')` for access to data models |
| 25 | + |
| 26 | +### Branches |
| 27 | +- master (runs in production) |
| 28 | + - Is never used to publish versions of subpackages |
| 29 | + - [package.json](package.json) contains specific versions from NPM |
| 30 | + - Is used for container build tags |
| 31 | +- development (runs on testing server) |
| 32 | + - Releases for subpackages are done from here |
| 33 | + - [package.json](package.json) contains `file:./api` and `file:./models` as versions |
| 34 | +- gh-pages |
| 35 | + - Hosts API docs for [https://docs.opensensemap.org/](https://docs.opensensemap.org/) |
| 36 | + - Is generated and pushed to github by Travis CI [](https://travis-ci.org/sensebox/openSenseMap-API) |
| 37 | + |
| 38 | +### Tags and Versions |
| 39 | +Git Tags are used for: |
| 40 | +- Docker hub builds `dockerhub-v1`. Version number is increased by one for each new version. |
| 41 | +- NPM tags for subpackages. [Uses Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html) |
| 42 | + - `@sensebox/opensensemap-api-v1.0.0` |
| 43 | + - `@sensebox/opensensemap-api-models-v1.0.0` |
| 44 | + |
| 45 | +### Release new NPM versions |
| 46 | +Make sure you've documented your changes in the `CHANGELOG.md` file of the respective package and have comitted everything to the development branch. |
| 47 | + |
| 48 | +To create a new NPM version, use `npm version`. |
| 49 | +1. Have everything commited for the release |
| 50 | +1. Document your changes in `CHANGELOG.md` under `## Unreleased`. Do not `git add` the file |
| 51 | +1. Run `npm version [ major | minor | patch ] -m "[<PACKAGENAME>-v%s] <Your commit message>"` |
| 52 | +1. `git push origin development` |
| 53 | +1. `npm publish` |
| 54 | + |
| 55 | +### Docker container images |
| 56 | +#### Development images |
| 57 | +Every commit on branch `development` will be built with the tag `development`. Versions of `@sensebox/opensensemap-api` and `@sensebox/opensensemap-api-models` will be the current development snapshot. |
| 58 | + |
| 59 | +#### Versioned container images |
| 60 | +- Check out `master` branch |
| 61 | +- Go to root directory |
| 62 | +- Modify version of `@sensebox/opensensemap-api` and `@sensebox/opensensemap-api-models` to desired versions |
| 63 | +- Make sure versions of `@sensebox/opensensemap-api` and `@sensebox/opensensemap-api-models` are published on NPM |
| 64 | +- Optional |
| 65 | + - Run tests |
| 66 | + - Build docker image locally |
| 67 | +- Run `yarn` to update `yarn.lock` |
| 68 | +- Commit `package.json` and `yarn.lock` |
| 69 | +- Run `npm run tag-container` |
| 70 | +- Run `git push origin master` |
| 71 | +- Docker images are built automatically by the Docker hub for all tags starting with `dockerhub-v` |
| 72 | + |
| 73 | +## Development |
| 74 | +- Have [Node.js] v6, [yarn](https://yarnpkg.com/), [Docker](https://docs.docker.com/engine/installation/) and [docker-compose](https://docs.docker.com/compose/install/) installed |
| 75 | +- Go to the subdirectory in which you want to develop |
| 76 | +- Only for [api](api): Run `yarn install` |
| 77 | +- Start your development database (`docker-compose up -d db`) |
| 78 | + |
| 79 | +## Running Tests |
| 80 | +You can run the tests in containers using Docker and docker-compose. |
56 | 81 | ```
|
57 | 82 | # Only run this once or every time you change dependencies in package.json
|
58 |
| -docker-compose -p osemapitest -f tests-docker-compose.yml build osem-api |
| 83 | +./run-tests.sh build |
59 | 84 |
|
60 | 85 | ./run-tests.sh
|
61 | 86 | ```
|
62 | 87 |
|
63 |
| -### Running in Production |
64 |
| - |
65 |
| -Look at the [OSeM-compose](https://github.com/sensebox/osem-compose) repository. It contains a deployment with docker compose. |
66 |
| - |
67 |
| -### License |
| 88 | +## Running the API |
| 89 | +### Configuration |
| 90 | +These packages read their configuration either from their respective `src/config.js` file or environment variables starting with `OSEM_`. Environment variables override values in `src/config.js`. |
68 | 91 |
|
69 |
| -[MIT](license.md) - Matthias Pfeil 2015 - 2017 |
| 92 | +### Container based |
| 93 | +The repository [OSeM-compose](https://github.com/sensebox/osem-compose) contains a deployment of all services with docker compose. The image built from this repository is called [`sensebox/opensensemap-api`](https://hub.docker.com/r/sensebox/opensensemap-api/). |
70 | 94 |
|
71 |
| -[node.js]:http://nodejs.org/ |
72 |
| -[MongoDB]:http://www.mongodb.com/ |
| 95 | +[openSenseMap]:https://opensensemap.org/ |
| 96 | +[senseBox]:https://sensebox.de/ |
0 commit comments