feat: accept tdpWatts and youtubeVideoId in performance submit/edit APIs
This commit is contained in:
@@ -95,6 +95,21 @@ export const performanceSubmitRoutes = new Elysia({ prefix: "/performance" })
|
|||||||
return { error: "Hardware not found" }
|
return { error: "Hardware not found" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate YouTube video ID format (11 alphanumeric + dash/underscore)
|
||||||
|
if (body.youtubeVideoId) {
|
||||||
|
const ytId = body.youtubeVideoId.trim()
|
||||||
|
if (!/^[a-zA-Z0-9_-]{11}$/.test(ytId)) {
|
||||||
|
set.status = 400
|
||||||
|
return { error: "Invalid YouTube video ID format (must be 11 characters)" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate TDP
|
||||||
|
if (body.tdpWatts !== null && body.tdpWatts !== undefined && body.tdpWatts <= 0) {
|
||||||
|
set.status = 400
|
||||||
|
return { error: "TDP must be greater than 0" }
|
||||||
|
}
|
||||||
|
|
||||||
// Create the performance entry
|
// Create the performance entry
|
||||||
const [entry] = await db
|
const [entry] = await db
|
||||||
.insert(performanceEntries)
|
.insert(performanceEntries)
|
||||||
@@ -115,6 +130,10 @@ export const performanceSubmitRoutes = new Elysia({ prefix: "/performance" })
|
|||||||
frameGenMethod: body.frameGenMethod ?? "none",
|
frameGenMethod: body.frameGenMethod ?? "none",
|
||||||
loadTimeSsd: body.loadTimeSsd ?? null,
|
loadTimeSsd: body.loadTimeSsd ?? null,
|
||||||
loadTimeSd: body.loadTimeSd ?? null,
|
loadTimeSd: body.loadTimeSd ?? null,
|
||||||
|
tdpWatts: body.tdpWatts ?? null,
|
||||||
|
youtubeVideoId: body.youtubeVideoId
|
||||||
|
? body.youtubeVideoId.trim()
|
||||||
|
: null,
|
||||||
launchOptions: body.launchOptions ?? null,
|
launchOptions: body.launchOptions ?? null,
|
||||||
settingsJson: body.settingsJson ?? null,
|
settingsJson: body.settingsJson ?? null,
|
||||||
userNotes: body.userNotes ?? null,
|
userNotes: body.userNotes ?? null,
|
||||||
@@ -203,6 +222,8 @@ export const performanceSubmitRoutes = new Elysia({ prefix: "/performance" })
|
|||||||
),
|
),
|
||||||
loadTimeSsd: t.Optional(t.Union([t.Number(), t.Null()])),
|
loadTimeSsd: t.Optional(t.Union([t.Number(), t.Null()])),
|
||||||
loadTimeSd: t.Optional(t.Union([t.Number(), t.Null()])),
|
loadTimeSd: t.Optional(t.Union([t.Number(), t.Null()])),
|
||||||
|
tdpWatts: t.Optional(t.Union([t.Number(), t.Null()])),
|
||||||
|
youtubeVideoId: t.Optional(t.Union([t.String(), t.Null()])),
|
||||||
launchOptions: t.Optional(t.Union([t.String(), t.Null()])),
|
launchOptions: t.Optional(t.Union([t.String(), t.Null()])),
|
||||||
settingsJson: t.Optional(
|
settingsJson: t.Optional(
|
||||||
t.Union([
|
t.Union([
|
||||||
|
|||||||
@@ -288,6 +288,20 @@ export const performanceVerifyRoutes = new Elysia({
|
|||||||
updateData.settingsJson = body.settingsJson
|
updateData.settingsJson = body.settingsJson
|
||||||
if (body.userNotes !== undefined)
|
if (body.userNotes !== undefined)
|
||||||
updateData.userNotes = body.userNotes
|
updateData.userNotes = body.userNotes
|
||||||
|
if (body.tdpWatts !== undefined) updateData.tdpWatts = body.tdpWatts ?? undefined
|
||||||
|
if (body.youtubeVideoId !== undefined) {
|
||||||
|
// Validate format
|
||||||
|
if (body.youtubeVideoId !== null) {
|
||||||
|
const ytId = body.youtubeVideoId.trim()
|
||||||
|
if (!/^[a-zA-Z0-9_-]{11}$/.test(ytId)) {
|
||||||
|
set.status = 400
|
||||||
|
return { error: "Invalid YouTube video ID format" }
|
||||||
|
}
|
||||||
|
updateData.youtubeVideoId = ytId
|
||||||
|
} else {
|
||||||
|
updateData.youtubeVideoId = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const [updated] = await db
|
const [updated] = await db
|
||||||
.update(performanceEntries)
|
.update(performanceEntries)
|
||||||
@@ -398,6 +412,8 @@ export const performanceVerifyRoutes = new Elysia({
|
|||||||
launchOptions: t.Optional(t.Union([t.String(), t.Null()])),
|
launchOptions: t.Optional(t.Union([t.String(), t.Null()])),
|
||||||
settingsJson: t.Optional(t.Union([t.Array(t.Any()), t.Null()])),
|
settingsJson: t.Optional(t.Union([t.Array(t.Any()), t.Null()])),
|
||||||
userNotes: t.Optional(t.Union([t.String(), t.Null()])),
|
userNotes: t.Optional(t.Union([t.String(), t.Null()])),
|
||||||
|
tdpWatts: t.Optional(t.Union([t.Number(), t.Null()])),
|
||||||
|
youtubeVideoId: t.Optional(t.Union([t.String(), t.Null()])),
|
||||||
antiCheatRelevant: t.Optional(t.Boolean()),
|
antiCheatRelevant: t.Optional(t.Boolean()),
|
||||||
antiCheatName: t.Optional(t.Union([t.String(), t.Null()])),
|
antiCheatName: t.Optional(t.Union([t.String(), t.Null()])),
|
||||||
antiCheatStatus: t.Optional(
|
antiCheatStatus: t.Optional(
|
||||||
|
|||||||
Reference in New Issue
Block a user