jamespfennell / transiter

Web service for transit data
https://demo.transiter.dev
MIT License
62 stars 7 forks source link

Use Jinja template engine for parameterizing system config files #47

Closed jamespfennell closed 4 years ago

jamespfennell commented 4 years ago

Breaks the system config API so better sooner rather than later.

jamespfennell commented 4 years ago

Example of the realtime feeds in the NYC subway described using a Jinja template YAML:

feeds:
{% 
for id_, mta_url_postfix in (
    ("7", "-7"),
    ("123456", ""),
    ("ACE", "-ace"),
    ("BDFM", "-bdfm"),
    ("G", "-g"),
    ("JZ", "-jz"),
    ("L", "-l"),
    ("NQRW", "-nqrw"),
    ("SIR", "-sir")
)
%}
  {{ id_ }}:
    http:
      url: "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs{{ mta_url_postfix }}"
      headers:
        X-API-KEY: "{{ mta_api_key }}"
    parser:
      custom: 'transiter_nycsubway.gtfsrealtimeparser:parse'
    auto_update:
      period: 5 seconds
{% endfor %}
jamespfennell commented 4 years ago

Done