-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
27 lines (23 loc) · 845 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import express from 'express'
import { register } from './dpsRegister.js'
const app = express()
const port = process.env.PORT || 80
// http://localhost:3000/register?scopeId=0ne0083E236&deviceId=dev01&deviceKey=MitioajcTQN4yMLVBTfIAN1omGtZP3knqEoE8yZ4I5c=&modelId=dtmi:Advantech:AIIS_3410P;1
app.get('/register', async (req, res) => {
const scopeId = req.query.scopeId
const deviceId = req.query.deviceId
const deviceKey = req.query.deviceKey
const modelId = req.query.modelId
console.log(deviceId, deviceKey)
if (scopeId && deviceId && deviceKey && modelId) {
const result = await register(scopeId, deviceId, deviceKey, modelId)
res.json(result)
res.end()
} else {
res.text('invalid params')
res.end()
}
})
app.listen(port, () => {
console.log(`dps-proxy app listening at http://localhost:${port}`)
})