Skip to content

Commit

Permalink
re move api files to root dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ubergesundheit committed Sep 8, 2017
1 parent bd54804 commit 3540c3a
Show file tree
Hide file tree
Showing 35 changed files with 710 additions and 2,374 deletions.
File renamed without changes.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ mongo-data
.env
doc/
revision

dev_run_migration.sh
File renamed without changes.
3 changes: 0 additions & 3 deletions .scripts/npm_start.js

This file was deleted.

20 changes: 11 additions & 9 deletions .scripts/npm_tag-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
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
#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')
currentVersion=$(git tag -l --sort=-v:refname | head -n 1 | tr -d 'v')

# Increment
newVersion=$(($currentVersion+1))

tagName="v$newVersion"

# tag new version
git tag "dockerhub-v$newVersion"
git tag "$tagName"

echo "Creation of new tag for docker hub was successful. New tag is 'dockerhub-v$newVersion'."
echo "Creation of new tag for docker hub was successful. New tag is '$tagName'."
echo "Please run 'git push origin master' to trigger the build on docker hub."
28 changes: 0 additions & 28 deletions .scripts/npm_version-update_changelog.js

This file was deleted.

2 changes: 1 addition & 1 deletion api/CHANGELOG.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @sensebox/opensensemap-api Changelog
# openSenseMap API Changelog

## Unreleased
- Initial Release after splitting api and models
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ RUN yarn install --pure-lockfile --production
# required because the prebuilt binaries are not compatible with musl
# remove when https://github.com/kelektiv/node.bcrypt.js/issues/528 is resolved
RUN npm rebuild bcrypt --build-from-source
COPY .scripts /usr/src/app/
COPY . /usr/src/app/

COPY .git /usr/src/app/
# for git 2.1.4
RUN echo -n $(git rev-parse --abbrev-ref HEAD) $(TZ=UTC git log --date=local --pretty=format:"%ct %h" -n 1) > revision; rm -rf .git

Expand Down
126 changes: 53 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,76 @@
# openSenseMap API
![openSenseMap API](https://raw.githubusercontent.com/sensebox/resources/master/images/openSenseMap_API_github.png)

[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/).
[![sensebox/openSenseMap-API Build Status](https://travis-ci.org/sensebox/openSenseMap-API.svg?branch=master)](https://travis-ci.org/sensebox/openSenseMap-API)

## Organization
This repository contains the Node.js package [@sensebox/opensensemap-api](https://www.npmjs.com/package/@sensebox/opensensemap-api), which is the HTTP REST API used by [https://opensensemap.org](https://opensensemap.org) running at [https://api.opensensemap.org](https://api.opensensemap.org). 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/). openSenseMap is part of the [senseBox] project.

Originally, this API has been built as part of the bachelor thesis of [@mpfeil](https://github.com/mpfeil) at the ifgi (Institute for Geoinformatics, WWU Münster) and is currently maintained by [@ubergesundheit](https://github.com/ubergesundheit).

## Configuration
Configuration values reside in the `lib/config.js` file. Configuration can also be set through environment variables starting with `OSEM_`. Environment variables override values in `lib/config.js`.

## 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
- Start your development database (`docker-compose up -d db`)
- Check out `development` branch (`git checkout development`)
- Run `yarn install`
- Create your own branch `git checkout -b my-awesome-branch`
- Commit your changes to your branch and push it to your fork
- Create a pull request against the `development` branch

## 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
./run-tests.sh build
./run-tests.sh
```

## Related projects
- openSenseMap Frontend
- sketch-templater
- ttn-integration
- models
- mqtt
- osem-compose

This repository is a monorepo for the packages

- [![@sensebox/opensensemap-api-models NPM Version](https://img.shields.io/npm/v/@sensebox/opensensemap-api-models.svg)](https://www.npmjs.com/package/@sensebox/opensensemap-api-models) [@sensebox/opensensemap-api-models](models) The data models and database connection of openSenseMap.
- [![@sensebox/opensensemap-api NPM Version](https://img.shields.io/npm/v/@sensebox/opensensemap-api.svg)](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
## Technologies

* [Node.js]
* [MongoDB]

## Organization

### 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
- Bleeding edge and possibly unstable development version
- gh-pages
- Hosts API docs for [https://docs.opensensemap.org/](https://docs.opensensemap.org/)
- Is generated and pushed to github by Travis CI [![sensebox/openSenseMap-API Build Status](https://travis-ci.org/sensebox/openSenseMap-API.svg?branch=master)](https://travis-ci.org/sensebox/openSenseMap-API)
- Is generated and pushed to github by Travis CI

### 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.
Git Tags are used for Docker hub builds (like `v1`). Version number is increased by one for each new version. Docker images are built automatically by the Docker hub for all tags starting with `v`

#### Development container images
Every commit on branch `development` will be built with the tag `development`.

#### 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 tests
- Optional: Build docker image locally
- Commit everything needed for the container image
- 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
./run-tests.sh build
./run-tests.sh
```

## 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`.
## License

### 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/).
[MIT](license.md) - Matthias Pfeil 2015 - now

[Node.js]:http://nodejs.org/
[MongoDB]:http://www.mongodb.com/
[openSenseMap]:https://opensensemap.org/
[senseBox]:https://sensebox.de/
33 changes: 0 additions & 33 deletions api/README.md

This file was deleted.

Empty file removed api/logs/.gitkeep
Empty file.
60 changes: 0 additions & 60 deletions api/package.json

This file was deleted.

Loading

0 comments on commit 3540c3a

Please sign in to comment.