GithubHelp home page GithubHelp logo

whytf / metar-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benjasper/metar.gg-backend

0.0 0.0 0.0 918 KB

Latest METAR, TAF and airport data delivered via GraphQL

Home Page: https://metar.gg

License: MIT License

Go 99.72% Dockerfile 0.28%

metar-backend's Introduction

metar.gg

πŸ›«β˜€οΈπŸŒ¦

Latest worldwide aviation weather and airport data, delivered via GraphQL

What is this?

metar.gg is a server written in Go that provides a GraphQL API, for querying the latest METARs, TAFs, airports and runways. It imports airport data from OurAirports.com and METAR and TAF data from NOAA.

You can either host it yourself or use the hosted version of this API available at rapidapi.com. The hosted version imports airport data every 7 days and weather data every 5 minutes, and retains the weather data for 7 days.

Features ✨

  • Imports Airports, METARs and TAFs
    • Hashing, for duplicate detection
    • Syncs all Airport Data and removes old ones
    • Timezone data for airports
    • Generate a sitemap for all airports with a weather station
  • GraphQL API
    • Unit Conversion API
    • Airport vicinity search
    • Next METAR Time Prediction
    • Search API
    • Pagination

Tech πŸ› 

  • Go
  • GraphQL
  • MySQL Database
  • ent: Entity framework for Go
  • gqlgen: GraphQL server library for Go
  • gin: Web framework for Go
  • Optional: Axiom for logging data ingestion

How to run ▢️

The easiest way to run the server is by using the Docker image. You only need to provide it with a MySQL database and off you go! πŸ›«

Environment

See .env.example to see what environment variables are required.

Compiling

You can also easily compile the server yourself and run the binary. See the Dockerfile for an example of how to compile the server.

How to access the GraphQL API

The GraphQL API is available at /graphql. You can use introspection to see what queries are available.

How to import data

You can either use the builtin CRON_* environment Variables (see .env.example) or use the HTTP API to trigger the imports. With the environment variables you are not dependent on another system, because the app will trigger the imports itself.

The server also has a few triggers to start the data import from the sources mentioned above. Those can be triggered via HTTP POST requests to:

  • POST /import/airports: Imports airport data
  • POST /import/weather: Imports weather data
  • POST /clean: Gets rid of old weather data see .env.example for the WEATHER_DATA_RETENTION_DAYS variable
  • POST /sitemap: Generate sitemap asynchronously
  • GET /health: Health check endpoint

❗️Send the requests including the secret (from the ADMIN_SECRET env variable) in the Authorization header.

In every case, the server will respond with a 204 No content if the import was successfully triggered. You can use some kind of cron service to trigger these endpoints at your desired intervals. The airport data is synced, while the weather data is will only be added and not automatically removed. You can use the /clean endpoint to remove old weather data.

Development πŸ’»

Prerequisites

Setup

  1. Clone the repository
  2. Run go mod download to download the dependencies
  3. Set up the environment variables in a .env file, see .env.example
  4. Run docker-compose up -d to start the database
  5. Run go run main.go to start the server

Development

Execute code generation with go generate ./...

Pull Requests

PRs are welcome! Please make sure to run go generate ./... before committing.

License πŸ“

MIT

metar-backend's People

Contributors

benjasper avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.