You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.3 KiB
JavaScript

4 years ago
const amqp = require('amqp-connection-manager')
// Create a connetion manager
const connection = amqp.connect([
'amqp://daemon:daemon@10.13.37.37:5672/'
])
connection.on('connect', () => console.log('Connected to AMQP.'))
connection.on('disconnect', err => console.log('Disconnected from AMQP.', err.stack))
4 years ago
const types = require('./types') // also initializes the registries, if they havent been loaded
4 years ago
types.ConnectorRegistry.register(new types.Connectors.POCSAGConnector(connection)) // activate POCSAG
types.DeviceRegistry.register(new types.devices.GenericPager())
types.DeviceRegistry.register(new types.devices.BirdySlim())
types.DeviceRegistry.register(new types.devices.Skyper())
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.json())
/*app.get('/api/message/easy', async (req, res) => {})*/
4 years ago
app.post('/api/message/advanced', async (req, res) => {
if (!req.body.type) return res.status(500).json("ERROR: no msg type(simple,duplex)")
if (!req.body.payload) return res.status(500).json("ERROR: no msg payload")
if (!req.body.routing) return res.status(500).json("ERROR: no msg routing")
let id = await types.MessageManager.New(req.body.type, req.body.routing, req.body.payload)
await types.MessageManager.Deliver(id)
return res.json(id)
})
4 years ago
app.listen(3000)