-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving around stuff, huge README update
- Loading branch information
1 parent
500a70a
commit bd54804
Showing
114 changed files
with
4,971 additions
and
1,986 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
require('@sensebox/opensensemap-api'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
currentBranch=$(git branch | grep -e "^*" | cut -d' ' -f 2) | ||
|
||
if [ "$currentBranch" != "master" ]; then | ||
echo "Tags for containers can only be made from 'master' branch" | ||
exit 1 | ||
fi | ||
|
||
# Extract latest git tag | ||
currentVersion=$(git tag -l --sort=-v:refname | grep dockerhub-v | head -n 1 | tr -d 'dockerhub\-v') | ||
|
||
# Increment | ||
newVersion=$(($currentVersion+1)) | ||
|
||
# tag new version | ||
git tag "dockerhub-v$newVersion" | ||
|
||
echo "Creation of new tag for docker hub was successful. New tag is 'dockerhub-v$newVersion'." | ||
echo "Please run 'git push origin master' to trigger the build on docker hub." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
/* | ||
NPM package.json version script. Do not run manually! | ||
Only tested on Linux. Node v6. | ||
This script overwrites the first Markdown headline "## Unreleased" with the | ||
version in the package.json and prepends a new "## Unreleased" headline. | ||
*/ | ||
|
||
const { version } = require('../package.json'), | ||
fs = require('fs'); | ||
|
||
const filename = 'CHANGELOG.md'; | ||
|
||
fs.readFile(filename, 'utf-8', function(err, data) { | ||
if (err) return console.log(err); | ||
const result = data.replace( | ||
/## Unreleased/i, | ||
`## Unreleased\n\n## v${version}` | ||
); | ||
|
||
fs.writeFile(filename, result, 'utf8', function(err) { | ||
if (err) return console.log(err); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,96 @@ | ||
openSenseMap-API | ||
================ | ||
|
||
[](https://gitter.im/sensebox/openSenseMap-API?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
This is the back-end for [openSenseMap](https://opensensemap.org). | ||
|
||
openSenseMap is part of the [senseBox](https://sensebox.de) 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). | ||
|
||
Originally, this API has been built as part the bachelor thesis of @mpfeil at the ifgi (Institute for Geoinformatics, WWU Münster). | ||
|
||
### Technologies | ||
|
||
* [node.js] | ||
* [MongoDB] | ||
|
||
### Development | ||
|
||
#### Node.js | ||
It is assumed that you have installed node.js Version 6 LTS. Install dependencies with [yarn](https://yarnpkg.com/) | ||
``` | ||
yarn install | ||
``` | ||
|
||
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. | ||
|
||
#### Database | ||
The API needs a running MongoDB instance with a `OSeM-api` database and credentials. | ||
|
||
The best way to run the database for development is to use the supplied `docker-compose.yml` and run | ||
``` | ||
docker-compose up -d db | ||
``` | ||
|
||
### `require()` openSenseMap-API for other projects | ||
|
||
You can require several parts of the API in other projects. | ||
|
||
Install it as dependency | ||
``` | ||
# for specific branch/commit/tag append #<branch/commit/tag> | ||
yarn add git://github.com/sensebox/openSenseMap-API.git | ||
``` | ||
|
||
This allows you to use parts like models and decoding in your own project. See `index.js`. | ||
|
||
### Create the JSDoc pages | ||
|
||
To create the documentation you need [apidocjs](http://apidocjs.com/) and run: | ||
``` | ||
apidoc -e node_modules/ | ||
``` | ||
|
||
### Running Tests | ||
You can run the tests in containers using docker and docker-compose. | ||
# openSenseMap API | ||
|
||
[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/). | ||
|
||
## Organization | ||
|
||
This repository is a monorepo for the packages | ||
|
||
- [](https://www.npmjs.com/package/@sensebox/opensensemap-api-models) [@sensebox/opensensemap-api-models](models) The data models and database connection of openSenseMap. | ||
- [](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). | ||
|
||
### Directories | ||
- root directory | ||
- not published on NPM | ||
- is used to build a Docker container image | ||
- contains tests (run with `./run-tests`) | ||
- [api](api) directory | ||
- NPM [@sensebox/opensensemap-api](https://www.npmjs.com/package/@sensebox/opensensemap-api) | ||
- [Changelog](api/CHANGELOG.md) | ||
- should not appear as dependency of other packages | ||
- [models](models) directory | ||
- NPM [@sensebox/opensensemap-api-models](https://www.npmjs.com/package/@sensebox/opensensemap-api-models) | ||
- [Changelog](models/CHANGELOG.md) | ||
- `require('@sensebox/opensensemap-api-models')` for access to data models | ||
|
||
### Branches | ||
- master (runs in production) | ||
- Is never used to publish versions of subpackages | ||
- [package.json](package.json) contains specific versions from NPM | ||
- Is used for container build tags | ||
- development (runs on testing server) | ||
- Releases for subpackages are done from here | ||
- [package.json](package.json) contains `file:./api` and `file:./models` as versions | ||
- gh-pages | ||
- Hosts API docs for [https://docs.opensensemap.org/](https://docs.opensensemap.org/) | ||
- Is generated and pushed to github by Travis CI [](https://travis-ci.org/sensebox/openSenseMap-API) | ||
|
||
### Tags and Versions | ||
Git Tags are used for: | ||
- Docker hub builds `dockerhub-v1`. Version number is increased by one for each new version. | ||
- NPM tags for subpackages. [Uses Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html) | ||
- `@sensebox/opensensemap-api-v1.0.0` | ||
- `@sensebox/opensensemap-api-models-v1.0.0` | ||
|
||
### Release new NPM versions | ||
Make sure you've documented your changes in the `CHANGELOG.md` file of the respective package and have comitted everything to the development branch. | ||
|
||
To create a new NPM version, use `npm version`. | ||
1. Have everything commited for the release | ||
1. Document your changes in `CHANGELOG.md` under `## Unreleased`. Do not `git add` the file | ||
1. Run `npm version [ major | minor | patch ] -m "[<PACKAGENAME>-v%s] <Your commit message>"` | ||
1. `git push origin development` | ||
1. `npm publish` | ||
|
||
### Docker container images | ||
#### Development images | ||
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. | ||
|
||
#### Versioned container images | ||
- Check out `master` branch | ||
- Go to root directory | ||
- Modify version of `@sensebox/opensensemap-api` and `@sensebox/opensensemap-api-models` to desired versions | ||
- Make sure versions of `@sensebox/opensensemap-api` and `@sensebox/opensensemap-api-models` are published on NPM | ||
- Optional | ||
- Run tests | ||
- Build docker image locally | ||
- Run `yarn` to update `yarn.lock` | ||
- Commit `package.json` and `yarn.lock` | ||
- Run `npm run tag-container` | ||
- Run `git push origin master` | ||
- Docker images are built automatically by the Docker hub for all tags starting with `dockerhub-v` | ||
|
||
## Development | ||
- 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 | ||
- Go to the subdirectory in which you want to develop | ||
- Only for [api](api): Run `yarn install` | ||
- Start your development database (`docker-compose up -d db`) | ||
|
||
## Running Tests | ||
You can run the tests in containers using Docker and docker-compose. | ||
``` | ||
# Only run this once or every time you change dependencies in package.json | ||
docker-compose -p osemapitest -f tests-docker-compose.yml build osem-api | ||
./run-tests.sh build | ||
./run-tests.sh | ||
``` | ||
|
||
### Running in Production | ||
|
||
Look at the [OSeM-compose](https://github.com/sensebox/osem-compose) repository. It contains a deployment with docker compose. | ||
|
||
### License | ||
## Running the API | ||
### Configuration | ||
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`. | ||
|
||
[MIT](license.md) - Matthias Pfeil 2015 - 2017 | ||
### Container based | ||
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/). | ||
|
||
[node.js]:http://nodejs.org/ | ||
[MongoDB]:http://www.mongodb.com/ | ||
[openSenseMap]:https://opensensemap.org/ | ||
[senseBox]:https://sensebox.de/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,11 @@ | |
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
|
||
# move to the build dir.. | ||
cd $TRAVIS_BUILD_DIR | ||
cd "$TRAVIS_BUILD_DIR" | ||
|
||
# install apidocs | ||
npm install -g [email protected] | ||
|
||
# deploy! | ||
npm install -g [email protected] | ||
|
||
# run apidoc | ||
apidoc -i . -f js -e node_modules | ||
|
@@ -42,6 +39,5 @@ git config user.email "[email protected]" | |
# commit | ||
git commit -m "apidoc build from ${TRAVIS_COMMIT} by Travis" | ||
|
||
# push to github! | ||
# push to github | ||
git push "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPO}.git" gh-pages | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# @sensebox/opensensemap-api Changelog | ||
|
||
## Unreleased | ||
- Initial Release after splitting api and models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# @sensebox/opensensemap-api | ||
|
||
This package contains the HTTP REST API for the openSenseMap. Originally, this API has been built as part the bachelor thesis of [@mpfeil](https://github.com/mpfeil) at the ifgi (Institute for Geoinformatics, WWU Münster). | ||
|
||
The package should never be required by any other package. If you want to use the openSenseMap models, look at [@sensebox/opensensemap-api-models](../models). | ||
|
||
## Development | ||
|
||
- Install Docker, Node.js v6, yarn | ||
- Run `yarn` in this directory | ||
- Run development database `docker-compose up -d db` | ||
|
||
Also see [README](../README.md) | ||
|
||
|
||
## Create the API documentation pages | ||
|
||
To create the documentation you need [apidocjs](http://apidocjs.com/) and run: | ||
``` | ||
apidoc -e node_modules/ | ||
``` | ||
|
||
## Technologies | ||
|
||
* [Node.js] | ||
* [MongoDB] | ||
|
||
## License | ||
|
||
[MIT](license.md) - Matthias Pfeil 2015 - 2017 | ||
|
||
[Node.js]:http://nodejs.org/ | ||
[MongoDB]:http://www.mongodb.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.