This project distributes transit alerts via ActivityPub, mainly sourcing from GTFS-realtime Service Alerts feeds. It's primarily built on top of the activitypub-express
library.
Currently, Transit Fedilerts is in beta. There may be bugs and features are limited. I welcome issues and pull requests!
The "official" instance lives at transit.alerts.social
transit-fedilerts
repo and install depdenciesservices.json
services.schema.json
(example below)services.json
by default, you can define a custom path with the environment variable SERVICES_JSON
Transit Fedilerts starts up as an HTTP server, but ActivityPub requires HTTPS. A reverse proxy, such as nginx, is recommended to provide SSL support. Setting DOMAIN
to localhost
will introduce problems; for local development, consider ngrok or other options that provide temporary domain names with SSL.
Transit Fedilerts uses dotenv for environment variables. |
Name | Required? | Description |
---|---|---|---|
DOMAIN |
X | Domain name for the server | |
MONGO_DB_NAME |
The name of the MongoDB db to use. Defaults to transitFedilerts |
||
MONGO_URI |
The connection URI for the Mongo instance. Defaults to mongodb://localhost:27017 |
||
NO_FETCH_ALERTS |
When present, the alert fetchers won't run. Useful for testing other components | ||
PORT |
Port to run the server on. Defaults to 8080 |
||
SERVICES_JSON |
Custom path to a services configuration file. Defaults to services.json |
services.json
The config file is intended to be flexible and handle multiple use cases. A service is defined as a single transit entity and translates into an account users can follow, and a feed as the alerts feed itself. This separation will allow for complex use cases, such as agencies whose alerts might be in multiple feeds or feeds which may contain alerts from multiple agencies.
Here's a simple implementation for a single agency with a single feed:
{
"services": [
{
"identifier": "commtrans",
"name": "Community Transit",
"iconUrl": "/commtrans.jpg"
}
],
"feeds": [
{
"url": "https://s3.amazonaws.com/commtrans-realtime-prod/alerts.pb",
"relatesTo": ["commtrans"]
}
]
}
Included in CT's feed are alerts for several Sound Transit routes. Perhaps we want to create a separate Sound Transit feed that includes just those routes:
{
"services": [
{
"identifier": "commtrans",
"name": "Community Transit",
"iconUrl": "/commtrans1.jpg"
},
{
"identifier": "soundtransit",
"name": "Sound Transit (CT)",
"iconUrl": "/soundtransit-ct1.jpg"
}
],
"feeds": [
{
"url": "https://s3.amazonaws.com/commtrans-realtime-prod/alerts.pb",
"relatesTo": [
"commtrans",
{
"identifier": "soundtransit",
"criteria": [
{
"routeId": {
"test": "^5\\d\\d$"
}
}
]
}
]
}
]
}
This will keep all CT-operated service in commtrans
and also push anything on an ST route to soundtransit
. We could also add feeds for King County Metro and Pierce Transit (the other operators of ST Express buses) and push those to soundtransit
based on similar criteria, optionally with additional services for each of them.
The goal of this project is primarily to support GTFS-realtime Service Alerts, but some non-standard formats are supported. Some implementation details and contribution guidelines:
./plugins
with the plugin ID as the folder name services.schema.json
and ./models/config.ts
./alerts/fetchFeed.ts
, which returns an array of every found service alertindex.ts
file with the parse method as the default exportThe following features are not supported but are on my radar for the future—pull requests that start on these are encouraged. They are in no order.
host
must be maintained when passed from the proxy