mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
code: prisma,dbal,bridge (1 files)
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
import { dirname } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const readStdin = async () => {
|
||||
const chunks = []
|
||||
for await (const chunk of process.stdin) {
|
||||
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)
|
||||
}
|
||||
return Buffer.concat(chunks).toString('utf-8')
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
try {
|
||||
await prisma.$connect()
|
||||
|
||||
const input = await readStdin()
|
||||
let payload = {}
|
||||
try {
|
||||
payload = input ? JSON.parse(input) : {}
|
||||
} catch {
|
||||
// ignore parse errors
|
||||
}
|
||||
|
||||
if (payload?.action === 'status') {
|
||||
console.log(JSON.stringify({ status: 'ok', version: 'native-prisma-bridge' }))
|
||||
return
|
||||
}
|
||||
|
||||
console.log(JSON.stringify({ status: 'ok', message: 'Native Prisma bridge ready', payload }))
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify({ status: 'error', error: error instanceof Error ? error.message : 'unknown' }))
|
||||
process.exit(1)
|
||||
} finally {
|
||||
await prisma.$disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
Reference in New Issue
Block a user