Skip to content

Latest commit

 

History

History
98 lines (71 loc) · 2.22 KB

README.md

File metadata and controls

98 lines (71 loc) · 2.22 KB

Scholar Reader API

The API server for the Scholar Reader application. For a given paper, the application needs to know about the citations, symbols, and other entities in that paper and where they are located. This server provides that data upon request.

To run the server, first install the dependencies:

npm install

If you haven't already, do the One Time Setup.

Then start the server:

npm start

To check that the server is running, call:

curl 0.0.0.0:3000/api/health

And you should see a response of 👍.

Examples of valid API calls can be found by looking at the routes in the api.ts script, or at the API calls made from the ui code in the ScholarReader.tsx file.

One Time Setup

The API uses several secrets at runtime to:

The API queries work without an API key, but will get rate limited if you make more than 100 queries in 5 minutes. This can happen relatively quickly during normal use of the application.

The database won't workout without the appropriate configuration.

You can get these values by getting in touch with an administrator. At the time of writing this, [email protected] is one. Once you have the values, put them in a file called config/secret.json. The result will look something like this:

{
  "database": {
    "password": "<password>",
    "host": "<hostname>",
    "database": "<dbname>",
    "user": "<user>"
  },
  "s2": {
    "apiKey": "<key>"
  },
  "adminToken": "<randomly-generated-token-for-write-access-to-apis>"
}

After doing this you can start your API server, which should now have the ability to freely query the database or S2's Public API.

Running the Tests

The tests use a local database that's run in docker. If you don't have docker installed, you'll need to install it first.

First, start the local database:

./bin/start_local_db.sh

Then run the tests:

npm test

After you're done you can stop the database like so:

docker stop scholarphi-db