Add simple express-based server for updates
This commit is contained in:
parent
4de6f44dfe
commit
f1f4c89526
|
@ -0,0 +1,40 @@
|
|||
const express = require('express')
|
||||
const crypto = require('crypto')
|
||||
const fs = require('fs/promises')
|
||||
|
||||
const app = express()
|
||||
|
||||
const buildUpdates = async () => {
|
||||
const files = await(fs.readdir('./public'))
|
||||
const r = /[^0-9]+([0-9.]+)\..*/
|
||||
|
||||
return files.map(file => ({
|
||||
version: file.match(r)[1],
|
||||
'update_link': `https://bb-addon.sagev.space/${file}`
|
||||
}))
|
||||
}
|
||||
|
||||
const buildJson = async () => {
|
||||
const uuid1 = '16f4f9af-ad27-41b7-adae-b0b08bc17b43'
|
||||
const uuid2 = 'svaillancourt@add123.com'
|
||||
const object = {
|
||||
addons: {}
|
||||
}
|
||||
const updates = await buildUpdates()
|
||||
object.addons[uuid1] = { updates }
|
||||
object.addons[uuid2] = { updates }
|
||||
// object.addons[`{${uuid1}}`] = { updates }
|
||||
// object.addons[`{${uuid2}}`] = { updates }
|
||||
return JSON.stringify(object, null, 2)
|
||||
}
|
||||
|
||||
app.use(express.static('public'))
|
||||
|
||||
app.get('/updates.json', (request, response) => {
|
||||
buildJson().then(json => response.send(json))
|
||||
//response.send(JSON.stringify(buildJson()))
|
||||
})
|
||||
|
||||
app.listen(5643, () => {
|
||||
console.log('Listen on the port 5643...')
|
||||
})
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "bb-addon-server",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^4.18.2"
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue