snooty-data-api

REST API for communicating between the Autobuilder and Snooty's Gatsby source plugin

Stars
1
Committers
8

snooty-data-api

Snooty Data API is a REST API that returns build artifacts for docs builds.

Setup

Node

Node 18 was used to start this project. Please make sure you have Node 18 installed locally. If you have nvm, you can run nvm use to switch to the expected version of Node.

Install

Use npm v8 to install dependencies:

npm ci

.env

Use the sample.env file to help configure a local .env file.

Database

If a local database is desired for development, make sure to install MongoDB Community Edition via Homebrew. Otherwise, an Atlas connection string should be used in your .env file with snooty_dev as the database.

The build data to be used by this API server is saved by the Autobuilder's Persistence Module. If using a local database, feel free to use the Persistence Module to help save bundled artifacts generated by the Snooty Parser.

Running

To start the server, run:

npm run dev

By default, the server should be accessible through http://localhost:3000/.

Testing

Tests are ran by Jest and rely on Supertest for testing Express route logic. MongoDB Memory Server is used to help perform MongoDB queries in tests without having to worry about running a local MongoDB instance.

To run tests, use:

npm run test

Linting

We use eslint for linting and prettier for formatting. prettier is configured to run on lint, so feel free to just use:

npm run lint

If there are errors flagged through prettier, use:

npm run format:fix

Releasing

To release a new version of the data API to production, tag a new version from the Releases page. That tag will then be promoted to prod.

Endpoints

The following are the base URLs for the Snooty Data API:

  • https://snooty-data-api.mongodb.com/
  • https://snooty-data-api.docs.staging.corp.mongodb.com/