Awesome
Airqmon API
GraphQL API and worker service for the Airqmon app.
Data providers and data stores
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.
Build
Install the dependencies by running yarn
and then run yarn run build
to compile TypeScript.
Deploy
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.
MongoDB
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.
Cron Job Monitoring
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.
Settings
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.