Skip to content

wmde/attribution-generator-api

Repository files navigation

Attribution Generator API

An API for generating attribution hints for images from Wikipedia and Wikimedia Commons.

Build Status

Prerequisites

You will need a few things to get started:

Configuration

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.

Getting started

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

Development tasks

We use npm scripts for development-related tasks:

  • Run linting: yarn lint, to autocorrect issues yarn lint --fix
  • Run tests: yarn test, to start in watch mode yarn test --watch
  • Generate / update the API documentation: yarn run apidoc

Debugging

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

Documentation

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.

Resources

The app communicates with the Wikimedia and Wikipedia APIs:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published