more routes

This commit is contained in:
Devin Zuczek
2026-06-30 22:32:08 -04:00
parent 3a3f96bba6
commit bf88bcc48f
14 changed files with 447 additions and 152 deletions
+1 -1
View File
@@ -445,7 +445,7 @@ const app = new Hono<App>({ strict: false })
// account row (a JSON blob in the shared accounts table) so it sticks.
if (savedImageType === SavedImageType.ProfileThumbnail) {
await c.env.DB.prepare(
"UPDATE accounts SET data = json_set(data, '$.ProfileImage', ?2) WHERE account_id = ?1"
"UPDATE accounts SET data = json_set(data, '$.profileImage', ?2) WHERE account_id = ?1"
)
.bind(id, name)
.run()
+5 -5
View File
@@ -44,12 +44,12 @@ beforeAll(async () => {
await env.DB.prepare(
`CREATE TABLE IF NOT EXISTS accounts (
data TEXT NOT NULL,
account_id INTEGER GENERATED ALWAYS AS (json_extract(data, '$.AccountId')) VIRTUAL,
username_lower TEXT GENERATED ALWAYS AS (lower(json_extract(data, '$.Username'))) VIRTUAL
account_id INTEGER GENERATED ALWAYS AS (json_extract(data, '$.accountId')) VIRTUAL,
username_lower TEXT GENERATED ALWAYS AS (lower(json_extract(data, '$.username'))) VIRTUAL
)`
).run()
await env.DB.prepare('INSERT OR IGNORE INTO accounts (data) VALUES (?1)')
.bind(JSON.stringify({ AccountId: 42, Username: 'Tester', ProfileImage: 'DefaultProfileImage.jpg' }))
.bind(JSON.stringify({ accountId: 42, username: 'Tester', profileImage: 'DefaultProfileImage.jpg' }))
.run()
})
@@ -374,11 +374,11 @@ describe('images', () => {
const { ImageName } = (await res.json()) as { ImageName: string }
expect(ImageName).toMatch(/^[0-9a-f]+\.jpg$/)
// The account row now points its ProfileImage at the uploaded key.
// The account row now points its profileImage at the uploaded key.
const row = await env.DB.prepare('SELECT data FROM accounts WHERE account_id = 42').first<{
data: string
}>()
expect(JSON.parse(row!.data).ProfileImage).toBe(ImageName)
expect(JSON.parse(row!.data).profileImage).toBe(ImageName)
})
test('POST /api/images/v4/uploadsaved 401s without a bearer token', async () => {