sql server + platine v2
All checks were successful
Deploy App / build (push) Successful in 2m15s
Deploy App / deploy (push) Successful in 27s

This commit is contained in:
valere
2026-02-06 22:52:02 +01:00
parent b8cc3d277d
commit 7fa6f6ccc8
14 changed files with 960 additions and 31 deletions

View File

@@ -7,7 +7,7 @@ export default eventHandler(async (event) => {
if (!slug) {
throw createError({
statusCode: 400,
statusMessage: 'ESID manquant dans la requête'
statusMessage: 'Slug manquant dans la requête'
})
}

15
server/api/card/random.ts Normal file
View File

@@ -0,0 +1,15 @@
import { useDB, schema } from '../../db'
import { sql } from 'drizzle-orm'
export default defineEventHandler(async (event) => {
const db = useDB()
const count = await db
.select({ count: sql<number>`count(*)` })
.from(schema.cards)
.get()
const randomOffset = Math.floor(Math.random() * count.count)
const randomCard = await db.select().from(schema.cards).limit(1).offset(randomOffset).get()
return randomCard
})

View File

@@ -14,7 +14,7 @@ export function getCardFromDate(date: Date): { suit: Suit; rank: Rank } {
? '♦'
: '♣'
const ranks: Rank[] = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
const ranks: Rank[] = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'V', 'D', 'R']
const rank = ranks[(day + hour) % ranks.length]
return { suit, rank }