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 .envIn case you need to generate secure app secrets, run scripts/gen-secret.
Install JavaScript dependencies:
yarn installTo start the server and restart it on file changes:
yarn watchTo simply start the server without restarts:
yarn startthen 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 startWe 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 debugtestThis 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 debugtestYou 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: