Skip to content

Commit 29e4809

Browse files
authored
Merge pull request #306 from developmentseed/develop
merging v1.7.0 ahead of v2 refactor
2 parents 11742c2 + fdd5ffd commit 29e4809

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+5014
-3570
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/node:12.16
5+
- image: circleci/node:14
66

77
environment:
88
DATABASE_URL: postgres://postgres@localhost/osm-teams-test

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
OSM_CONSUMER_KEY=<osm-consumer-key>
22
OSM_CONSUMER_SECRET=<osm-consumer-secret>
3-
DSN=postgres://postgres@host.docker.internal/osm-teams?sslmode=disable
3+
DSN=postgres://postgres@dev-db/osm-teams?sslmode=disable

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ node_modules.nosync
1111
.idea
1212
hydra-config/prod/prod.yml
1313
.nyc_output
14-
coverage
14+
coverage
15+
docker-data/*

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v12.16
1+
14

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:lts
1+
FROM node:14
22

33
# Create app directory
44
WORKDIR /usr/src/app

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Development Seed
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,30 @@
1616
Check the beta 👉 <!-- markdownlint-disable MD034 -->https://mapping.team
1717
<!-- markdownlint-enable MD034 -->
1818

19+
## Development
1920

20-
## Installation
21+
Install requirements:
2122

22-
### Requirements
23+
- [nvm](https://github.com/creationix/nvm)
24+
- [Docker](https://www.docker.com)
2325

24-
- [PostgreSQL](https://www.postgresql.org). On OS X, the easiest is to install [Postgres.app](https://postgresapp.com/).
25-
- [Node.js](https://nodejs.org) v12.16+
26-
- [Docker](https://www.docker.com/) & Docker Compose
26+
Visit your [OpenStreetMap settings](https://www.openstreetmap.org/account/edit) page and register an OAuth1 Client App:
2727

28-
### Setting up Hydra
28+
![OSM Client App](oauth1-osm-client-app.png "OAuth1 page at OSM Website")
2929

30-
1. Create the database for tokens
31-
32-
```bash
33-
createdb osm-teams
34-
createdb osm-teams-test
35-
```
36-
37-
For the rest of this documentation, we will assume that the database location is `postgres://postgres@localhost/osm-teams?sslmode=disable` on your local machine. Inside docker, that location is `postgres://[email protected]/osm-teams?sslmode=disable`
38-
39-
1. Create an `.env` file by copying `.env.sample` and replacing the values as needed. `OSM_CONSUMER_KEY` and `OSM_CONSUMER_SECRET` are values obtained by creating a new OAuth app on openstreetmap.org. The .env file can contain:
30+
Create an `.env` file by copying `.env.sample` and replacing the values as needed. `OSM_CONSUMER_KEY` and `OSM_CONSUMER_SECRET` are values available at the OAuth app page on openstreetmap.org. The .env file should contain:
4031

4132
```bash
4233
OSM_CONSUMER_KEY=<osm-teams-app>
4334
OSM_CONSUMER_SECRET=<osm-teams-app-secret>
44-
DSN=postgres://[email protected]/osm-teams?sslmode=disable
45-
```
46-
47-
1. Build the docker images:
48-
49-
```bash
50-
docker-compose -f compose.yml build
51-
```
52-
53-
1. Start Hydra and the server
54-
55-
```bash
56-
docker-compose -f compose.yml -f compose.dev.yml up
35+
DSN=postgres://postgres@dev-db/osm-teams?sslmode=disable
5736
```
5837

59-
⚠️ In development, `docker-compose -f compose.yml -f compose.dev.yml up` enables hot module reloading while you make modifications to the code. `docker-compose up` should be used for production/staging deployments.
60-
61-
This will start hydra where the token issuer is at `http://localhost:4444` and the admin interface is at `http://localhost:4445`. This also sets up the consent and login interface at `http://localhost:8989` (where we will create a first-party oauth app)
38+
Start Hydra and PostgreSQL with Docker:
6239

63-
### Setting up the OSM-teams app
40+
docker-compose -f compose.dev.yml up --build
6441

65-
Create the [first-party](https://auth0.com/docs/applications/concepts/app-types-first-third-party) "manage" app
42+
On a separate terminal, create the [first-party](https://auth0.com/docs/applications/concepts/app-types-first-third-party) "manage" app:
6643

6744
```bash
6845
docker-compose exec hydra hydra clients create --endpoint http://localhost:4445 \
@@ -74,6 +51,22 @@ docker-compose exec hydra hydra clients create --endpoint http://localhost:4445
7451
--callbacks http://localhost:8989/login/accept
7552
```
7653

54+
Install Node.js the required version (see [.nvmrc](.nvmrc) file):
55+
56+
nvm i
57+
58+
Install Node.js modules:
59+
60+
yarn
61+
62+
Migrate `dev-db` database:
63+
64+
yarn migrate
65+
66+
Start development server:
67+
68+
yarn dev
69+
7770
<!-- markdownlint-disable MD034 -->
7871
✨ You can now login to the app at http://localhost:8989
7972
<!-- markdownlint-enable MD034 -->

app/db/knexfile.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
let DATABASE_URL
1+
let DATABASE_URL = process.env.DSN || process.env.DATABASE_URL
22

3-
if (!process.env.NODE_ENV) {
4-
process.env.NODE_ENV = 'development'
5-
}
6-
7-
if (process.env.DSN) {
8-
DATABASE_URL = process.env.DSN
9-
} else {
10-
if (process.env.NODE_ENV === 'development') {
11-
DATABASE_URL = 'postgres://postgres@localhost/osm-teams?sslmode=disable'
3+
// Apply defaults if no connection string is passed
4+
if (!DATABASE_URL) {
5+
if (!process.env.NODE_ENV || process.env.NODE_ENV === 'development') {
6+
DATABASE_URL =
7+
'postgres://postgres:postgres@localhost:5433/osm-teams?sslmode=disable'
128
} else if (process.env.NODE_ENV === 'test') {
13-
DATABASE_URL = 'postgres://postgres@localhost/osm-teams-test?sslmode=disable'
9+
DATABASE_URL = 'postgres://postgres:postgres@localhost:5434/osm-teams-test?sslmode=disable'
1410
}
1511
}
1612

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
exports.up = async function (knex) {
3+
await knex.schema.alterTable('organization', table => {
4+
table.json('privacy_policy')
5+
})
6+
}
7+
8+
exports.down = async function (knex) {
9+
await knex.schema.alterTable('organization', table => {
10+
table.dropColumn('privacy_policy')
11+
})
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
exports.up = async function (knex) {
2+
await knex.schema.createTable('organization_badge', (table) => {
3+
table.increments('id')
4+
table
5+
.integer('organization_id')
6+
.references('id')
7+
.inTable('organization')
8+
.onDelete('CASCADE')
9+
table.string('name').notNullable()
10+
table.string('color').notNullable()
11+
})
12+
}
13+
14+
exports.down = async function (knex) {
15+
await knex.schema.dropTable('organization_badge')
16+
}

0 commit comments

Comments
 (0)