zenstack/packages/server/test/utils.ts
Yiming Cao 56b68ab9cc
feat(server): migrate rpc api handler and express adapter (#328)
* feat(server): migrate rpc api handler and express adapter

* fix package.json

* misc fixes

* update

* update ot express5 only

* update

* update

* fix test
2025-10-23 19:05:05 -07:00

33 lines
887 B
TypeScript

import superjson from 'superjson';
export const schema = `
model User {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
email String @unique @email
posts Post[]
@@allow('all', auth() == this)
@@allow('create,read', true)
}
model Post {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String
author User? @relation(fields: [authorId], references: [id])
authorId String?
published Boolean @default(false)
publishedAt DateTime?
viewCount Int @default(0)
@@allow('all', author == auth())
@@allow('read', published)
}
`;
export function makeUrl(path: string, q?: object, useSuperJson = false) {
return q ? `${path}?q=${encodeURIComponent(useSuperJson ? superjson.stringify(q) : JSON.stringify(q))}` : path;
}