55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
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}`
|
|
}))
|
|
}
|
|
|
|
/**
|
|
* {
|
|
* addons: {
|
|
* [stringId1]: {
|
|
* updates: [
|
|
* {
|
|
* version: '1.0.9.xpi',
|
|
* update_link: `https://bb-addon.sagev.space/${file}`
|
|
* },
|
|
* ...
|
|
* ]
|
|
* },
|
|
* [stringId2]: ...
|
|
* }
|
|
* }
|
|
*/
|
|
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 }
|
|
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...')
|
|
})
|