mirror of
https://github.com/ArthurDanjou/website.git
synced 2026-01-14 12:14:42 +01:00
Import drizzle replacing prisma
Signed-off-by: Arthur DANJOU <arthurdanjou@outlook.fr>
This commit is contained in:
14
server/utils/db.ts
Normal file
14
server/utils/db.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { drizzle } from 'drizzle-orm/postgres-js'
|
||||
import postgres from 'postgres'
|
||||
import * as schema from '../database/schema'
|
||||
|
||||
export const tables = schema
|
||||
export { sql, eq, and, or, asc, desc, sum, inArray } from 'drizzle-orm'
|
||||
|
||||
// eslint-disable-next-line node/prefer-global/process
|
||||
const connectionString = process.env.DATABASE_URL as string
|
||||
const client = postgres(connectionString, { prepare: false })
|
||||
|
||||
export function useDB() {
|
||||
return drizzle(client, { schema })
|
||||
}
|
||||
28
server/utils/discord.ts
Normal file
28
server/utils/discord.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { RuntimeConfig } from 'nuxt/schema'
|
||||
|
||||
interface WebhookContent {
|
||||
title: string
|
||||
description: string
|
||||
color: number
|
||||
}
|
||||
|
||||
export async function sendDiscordWebhookMessage(config: RuntimeConfig, content: WebhookContent) {
|
||||
await $fetch(`https://discordapp.com/api/webhooks/${config.discordId}/${config.discordToken}`, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
embeds: [
|
||||
{
|
||||
title: content.title,
|
||||
description: content.description,
|
||||
color: content.color,
|
||||
url: 'https://arthurdanjou.fr/talents',
|
||||
footer: {
|
||||
text: 'Powered by Nuxt'
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
],
|
||||
username: 'ArtDanjRobot - Website'
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user