Add simple express-based server for updates

This commit is contained in:
Sage Vaillancourt 2023-12-04 20:30:39 -05:00
parent 4de6f44dfe
commit f1f4c89526
8 changed files with 1182 additions and 0 deletions

40
index.js Normal file
View File

@ -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...')
})

1127
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

15
package.json Normal file
View File

@ -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.