Function
findWidgetByType
(projectId: string, type: string)
Source from the content-addressed store, hash-verified
| 17 | |
| 18 | // Helper to find widget by projectId and type |
| 19 | async function findWidgetByType(projectId: string, type: string) { |
| 20 | const widgets = await db.shareWidget.findMany({ |
| 21 | where: { projectId }, |
| 22 | }); |
| 23 | return widgets.find( |
| 24 | (w) => (w.options as z.infer<typeof zWidgetOptions>)?.type === type |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | export const widgetRouter = createTRPCRouter({ |
| 29 | // Get widget by projectId and type (returns null if not found or not public) |
Tested by
no test coverage detected