Add a way to get splash texts
This commit is contained in:
@@ -45,6 +45,8 @@ import { handler as berryDashAccountSavePostHandler } from './routes/berrydash/a
|
||||
|
||||
import { handler as berryDashChatroomReportPostHandler } from './routes/berrydash/chatroom/report/post'
|
||||
|
||||
import { handler as berryDashSplashTextGetHandler } from './routes/berrydash/splash-text/get'
|
||||
|
||||
dotenv.config({ quiet: true })
|
||||
|
||||
const intNotStr = (name: string) => {
|
||||
@@ -950,6 +952,12 @@ app.post(
|
||||
})
|
||||
}
|
||||
)
|
||||
app.get('/berrydash/splash-text', berryDashSplashTextGetHandler, {
|
||||
detail: {
|
||||
description: 'The endpoint for getting splash texts.',
|
||||
tags: ['Berry Dash', 'Splash Texts']
|
||||
}
|
||||
})
|
||||
app.all('*', () =>
|
||||
jsonResponse(
|
||||
{
|
||||
|
||||
@@ -142,3 +142,11 @@ export const berryDashMarketplaceIcons = mysqlTable('marketplaceicons', {
|
||||
.autoincrement()
|
||||
.notNull()
|
||||
})
|
||||
|
||||
export const berryDashSplashTexts = mysqlTable('splashtexts', {
|
||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
||||
userId: bigint('userId', { mode: 'number' }).notNull(),
|
||||
content: varchar('content', { length: 72 }).notNull(),
|
||||
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
|
||||
state: tinyint('state').default(0).notNull()
|
||||
})
|
||||
|
||||
29
src/routes/berrydash/splash-text/get.ts
Normal file
29
src/routes/berrydash/splash-text/get.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { getDatabaseConnection } from '../../../lib/util'
|
||||
import { berryDashSplashTexts } from '../../../lib/tables'
|
||||
import { eq } from 'drizzle-orm'
|
||||
|
||||
export async function handler () {
|
||||
const dbInfo1 = getDatabaseConnection(1)
|
||||
|
||||
if (!dbInfo1)
|
||||
return new Response('', {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'text/plain' }
|
||||
})
|
||||
const { connection: connection1, db: db1 } = dbInfo1
|
||||
|
||||
const result = await db1
|
||||
.select({
|
||||
content: berryDashSplashTexts.content
|
||||
})
|
||||
.from(berryDashSplashTexts)
|
||||
.where(eq(berryDashSplashTexts.state, 1))
|
||||
.execute()
|
||||
|
||||
connection1.end()
|
||||
|
||||
return new Response(result.map(i => atob(i.content)).join('\n'), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'text/plain' }
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user