Add authorization header to versions (not in use yet)

This commit is contained in:
Lncvrt committed 2026-10-02 10:47:59 -07:00
1 parent c205c1bdaf
commit a433f57a58
3 files changed
+22 -16

No files matched your search

+5 -4
View File
@@ -179,11 +179,11 @@ setInterval(async () => {
app.ws('/ws', {
maxPayloadLength: 10 * 1024 * 1024,
open (ws) {
open(ws) {
clients.add(ws)
// console.log(ws.id, 'connected')
},
async message (ws, message: any) {
async message(ws, message: any) {
console.log('received:', message, 'from', ws.id)
if (message == 'ping') ws.send('ping')
if (message.type) {
@@ -903,7 +903,7 @@ app.ws('/ws', {
}
}
},
async close (ws) {
async close(ws) {
clients.forEach(client => {
if (client.id === ws.id) clients.delete(client)
})
@@ -986,7 +986,8 @@ app.get('/launcher/versions', context => launcherVersionsHandler(context), {
hide: true
})
),
clientplatform: t.Optional(t.String())
clientplatform: t.Optional(t.String()),
authorization: t.Optional(t.String())
})
})
app.get('/launcher/latest', launcherLatestHandler, {
+12 -12
View File
@@ -41,19 +41,19 @@ export const getDatabaseConnection = (type: number) => {
const env =
type === 0
? {
host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT) || 3306,
user: process.env.GAMES_DB_USER ?? '',
pass: process.env.GAMES_DB_PASS ?? '',
name: process.env.GAMES_DB_NAME ?? ''
}
host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT) || 3306,
user: process.env.GAMES_DB_USER ?? '',
pass: process.env.GAMES_DB_PASS ?? '',
name: process.env.GAMES_DB_NAME ?? ''
}
: {
host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT) || 3306,
user: process.env.BERRYDASH_DB_USER ?? '',
pass: process.env.BERRYDASH_DB_PASS ?? '',
name: process.env.BERRYDASH_DB_NAME ?? ''
}
host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT) || 3306,
user: process.env.BERRYDASH_DB_USER ?? '',
pass: process.env.BERRYDASH_DB_PASS ?? '',
name: process.env.BERRYDASH_DB_NAME ?? ''
}
const connection = mysql.createConnection({
host: env.host,
+5
View File
@@ -9,6 +9,11 @@ export const handler = async (context: Context) => {
return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult
const authorization =
context.headers.authorization?.trim() == '' ||
context.headers.authorization == null
? null
: context.headers.authorization
const clientplatform = context.headers.clientplatform
const platform = clientplatform?.split('-')[0]
const arch = clientplatform?.split('-')[1]