An API for generating attribution hints for images from Wikipedia and Wikimedia Commons.
You will need a few things to get started:
All of the application's configuration is read from environment variables.
If a .env
file is present in the current working directory, the application reads it via dotenv
when starting.
For a quick start in development, just copy .env.test
and update its values:
cp .env.test .env
In case you need to generate secure app secrets, run scripts/gen-secret
.
Install JavaScript dependencies:
yarn install
To start the server and restart it on file changes:
yarn watch
To simply start the server without restarts:
yarn start
then connect to localhost:8080 (and any API endpoint in there) to use the app.
To bind to a different port start the app with
PORT=9000 yarn start
We use npm scripts for development-related tasks:
- Run linting:
yarn lint
, to autocorrect issuesyarn lint --fix
- Run tests:
yarn test
, to start in watch modeyarn test --watch
- Generate / update the API documentation:
yarn run apidoc
You can debug this application with ndb
by running yarn debug
. Set break points in the pop-up window and run the test file in the terminal tab of the pop-up window.
In the debug window, run the tests within the supplied terminal using:
yarn debugtest
This lets all test run sequentially to avoid concurrency issues.
It can be useful to run tests with the DEBUG
flag enabled in order to get more information on errors:
DEBUG=true yarn debugtest
You can open http://localhost:8080/docs to browse the API documentation or http://localhost:8080/swagger to see the raw openapi.json
output to be used in other tools.
The app communicates with the Wikimedia and Wikipedia APIs: