To set the Node version as specified above:
$ brew install nvm
$ nvm use
See this tutorial for details and instructions for installing PostgreSQL on your operating system
Scoreboard depends on three external services/APIs for statistics and functionality:
Create a .env
file by copying the .env.sample
file and filling in the
required values. The sample file has comments above each possible environment
variable.
$ yarn
$ docker-compose up # wait for scoreboard_wait-for-db-ready_1
This command will create and run the database on port 5433
. The database files are stored under .tmp
folder.
If you are running the command for the first time, you should wait until the databases are created. This can take a few minutes.
To start with a new database with no data, stop the command, remove the .tmp
folder and run the command again.
Set up the database schema by running:
$ yarn migrate
You can rollback migrations with yarn rollback
.
For the frontend and the API to work, you must have the data loaded on the local database.
To generate fake user and campaign data run:
$ yarn seed
To be able to develop admin pages you'll need to have an admin user. Make your user an admin by running:
./api/bin/scoreboard create-admin-user --username {your osm username}
If you were already logged in, log out and log back in, then you'll see an "admin" link in the menu in the top right.
Known issue: before running create-admin-user
for username, you first have to login to the web app with that username first.
It could be useful to give some edits to your user in development.
You can run:
./api/bin/scoreboard create-edits --osm-id {your osm id}
This will select some random changesets from the OSMesa edits and assign them to your osm id
This command will start both the frontend and the api together, with livereloading for both the front end and api
$ yarn dev
This command will start both the frontend and the api together, with a static version of the api $ yarn dev-static
Tests for the API endpoints and related code are stored in api/tests/ and UI tests are stored in tests/. To run both:
$ yarn test
Test the UI and API separately using yarn test-ui
and yarn test-api
.
Lint the code using:
$ yarn lint
You can automatically fix some lint errors using yarn lintfix
.
If you make changes to the API documentation make sure to update the README for the API which is auto-generated from the swagger YAML by running:
$ yarn docs
In OSM-teams, choose "Connect a new app". For the callback URL use the path
/auth/teams/accept
For example in development, Scoreboard runs on localhost:8181, so the
callback URL would be http://localhost:8181/auth/teams/accept
.
The client id and client secret should be saved to your Scoreboard .env
file.
Scoreboard will work with a single organization at the moment. In osm-teams, record your organization's
ID from the API and use the environment variable OSM_TEAMS_ORG_ID
to have scoreboard read and write
to the organization's teams.
If you are setting up local development for the first time, you may need to create an organization. There is currently no way to do this via the osm teams interfaces. Instead you can use the swagger UI to make the requests.
1) check to see what organizations exist on your local osm-teams
2) if there is none, create an organization (the id can be anything, but should match OSM_TEAMS_ORG_ID
in your scoreboard .env
)
3) run yarn seed
4) clear your cache and login
The Administrator Settings are found in the Admin user's dashboard, or via the Admin entry in the User menu.
A pg_dump of osm-fabricator is used to mock the osmesa db when developing locally.
To update the osmesa db, first develop on osm-fabricator, then pg_dump it into docker-context/osmesa-mock/init.sql
.
See scoreboard's docker-compose.yml
for more details.
See api/README
To use scoreboard in production follow these steps:
yarn
.env
file with correct values -> example.
NODE_ENV=production
in your .env
filenpm run migrate
npm run seed
npm run users
npm run clocks
./api/bin/scoreboard create-admin-user --osm-id {your-id}
npm run build
node server.js