GraphQL API and worker service for the Airqmon app.
The API currently only supports Airly as a data provider but can be easily extended by adding more data sources. The Airly data provider servers as an example implementation of the Apollo RESTDataSource, while the MongoDB data store as an example of the IDataStore interface.
Install the dependencies by running yarn
and then run yarn run build
to compile TypeScript.
The easiest way to deploy and run the Airqmon server components is to use a PaS provider like Railway, Render, Heroku or any other PaaS that supports Node.js buildpack for deployment.
If you want a self-hosted solution, check Dokku. To simplify the setup, you can use the DigitalOcean 1-Click App with Dokku.
Whatever you choose, you will also need a MongoDB database to cache the sensor stations and measurements.
Render allows running MongoDB as a private service, Railway to add a MongoDB service, MongoDB Atlas integrates easily with Heroku applications, and Dokku has an excellent plugin for managing a self-hosted MongoDB database.
The Agenda worker can make an HTTP request each time a task completes. You can use a service like Healthchecks.io to monitor whether the stations-sync tasks succeeded.
The API server and tasks worker use Convict for loading and managing configuration. See the common/config.ts for schema and default options.
Create a production.json
file in the config
directory and provide at least the API key and MongoDB connection string.
{
"apiKeys": {
"airly": {
"key": "YOUR_AIRLY_API_KEY",
"rateLimitDay": 1000,
"rateLimitMinute": 50
}
},
"mongodb": "MONGODB_CONNECTION_URI"
}
Alternatively, you can use the environment variables to configure some of the settings.