{"id":13566816,"url":"https://github.com/bradtech/lora2db","last_synced_at":"2025-04-04T00:32:19.931Z","repository":{"id":198251757,"uuid":"700283274","full_name":"bradtech/lora2db","owner":"bradtech","description":"Typescript package to manage Lorawan message queues and push data to timeserie databases","archived":false,"fork":false,"pushed_at":"2024-06-17T07:22:58.000Z","size":24226,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-04T21:37:12.551Z","etag":null,"topics":["lorawan","time-series"],"latest_commit_sha":null,"homepage":"https://lora2db.brad.community/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bradtech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-04T09:52:26.000Z","updated_at":"2024-05-15T19:01:58.000Z","dependencies_parsed_at":"2023-10-05T02:29:39.934Z","dependency_job_id":"f1089703-9433-4114-ac9d-ce1fddf02cde","html_url":"https://github.com/bradtech/lora2db","commit_stats":null,"previous_names":["bradtech/lora2influx","bradtech/lora2db"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradtech%2Flora2db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradtech%2Flora2db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradtech%2Flora2db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradtech%2Flora2db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bradtech","download_url":"https://codeload.github.com/bradtech/lora2db/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247103290,"owners_count":20884023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lorawan","time-series"],"created_at":"2024-08-01T13:02:17.338Z","updated_at":"2025-04-04T00:32:19.435Z","avatar_url":"https://github.com/bradtech.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# lora2db\n\n[![Test, build and publish module CI](https://github.com/bradtech/lora2db/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/bradtech/lora2db/actions/workflows/build.yml)\n\n## Description\n\nLora2db is a Typescript packages stack that helps you manage Lorawan message queues, manipulate data and push it to time series databases. It's a project that is used on a daily basis here at Brad Technology.\n\n## Get started\n\nFirst, install the `@bradtech/lora2db` module with your favorite package manager\n\n```sh\nnpm i @bradtech/lora2db\n# OR\nbun add @bradtech/lora2db\n```\n\n... and then download a provider and a forwarder that suit your needs, among:\n\n```bash\n# Providers\n@bradtech/lora2db-provider-ttn\n@bradtech/lora2db-provider-orange\n\n# Forwarders\n@bradtech/lora2db-fwdr-influx\n@bradtech/lora2db-fwdr-timestream\n```\n\nThese packages will manage I/O in your stead, so that you can focus on your business logic and deploy quickly.\n\n### Providers\n\nA provider will listen for data coming in, and a forwarder will send your processed data to the DBMS or service of your choice.\n\nProviders classes need to be declared before starting the client. We are now supporting only MQTT-based providers. This may change in the future.\n\n```ts\nimport { TTNProvider } from '@bradtech/lora2db-provider-ttn'\n\nAbstractProvider.registerAdapter(TTNProvider, 'ttn')\n```\n\n#### Decoders\n\nYou must declare at least one decoder to process the payload coming from your provider.\n\nWe provide the `CayenneDecoder` class but you can write your own by extending the `AbstractDecoder` class.\n\n```ts\nclient.addDecoder(new CayenneDecoder(/* config map */), port)\n```\n\nYou may declare as many decoders as you want, each being bound to an unique Lorawan port.\n\nWe use a specific decoder that allows us to improve payload compression and reduce data loss. We plan to publish it in the near future. Feel free to contact us about it.\n\n### Middlewares\n\nMiddlewares are classes that receive data in the form of a `ProcessingMessage` instance. They are able to manipulate and enrich it. This can be done with internal functions but also by calling external APIS for example.\n\n```ts\nclient.addMiddleware(/* config map */)\n```\n\nYou can chain as many middlewares as you want. They are called one after the other, with respect of their order of injection. \n\n## How to use\n\nExample using Bun.\n\n```ts\nimport {\n   MQTTClient,\n   CayenneDecoder,\n   AbstractProvider,\n   CompressedDecoder,\n} from '@bradtech/lora2db'\nimport { TTNProvider } from '@bradtech/lora2db-provider-ttn'\nimport { OrangeProvider } from '@bradtech/lora2db-provider-orange'\nimport { InfluxDBForwarder } from '@bradtech/lora2db-fwdr-influx'\n\n// First, you'll need to register your providers\nAbstractProvider.registerAdapter(TTNProvider, 'ttn')\nAbstractProvider.registerAdapter(OrangeProvider, 'orange')\n\nconst {\n    LORA_PROVIDER,\n    LORA_MQTT_URL,\n    LORA_MQTT_USERNAME,\n    LORA_MQTT_TOPIC,\n    LORA_API_KEY,\n} = Bun.env\n\nconst port = 2\n\n// Then, you'll have to instantiate a client...\nconst client = new MQTTClient({\n    url: LORA_MQTT_URL,\n    username: LORA_MQTT_USERNAME,\n    password: LORA_API_KEY,\n    topic: LORA_MQTT_TOPIC,\n    provider: LORA_PROVIDER,\n})\n\n// ... and inject your port-based decoders into it\nclient.addDecoder(new CayenneDecoder({ ... }), port)\n\n// You can also inject middlewares to do some processing before forwarding the data\nclient.addMiddleware(...)\n\n// Inject your forwarder\nclient.addForwarder(\n    new InfluxDBForwarder({\n        INFLUX_HOST: Bun.env.INFLUX_HOST,\n        INFLUX_TOKEN: Bun.env.INFLUX_TOKEN,\n        INFLUX_ORG: Bun.env.INFLUX_ORG,\n        INFLUX_BUCKET: Bun.env.INFLUX_BUCKET,\n    }),\n)\n\n// And finally, listen to queue\nclient.listen()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradtech%2Flora2db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbradtech%2Flora2db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradtech%2Flora2db/lists"}