+12
-4
apps/api/src/xrpc/blue.recipes.feed.getRecipes.ts
+12
-4
apps/api/src/xrpc/blue.recipes.feed.getRecipes.ts
···
3
3
import { BlueRecipesFeedGetRecipes, BlueRecipesFeedRecipe } from '@cookware/lexicons';
4
4
import { json, XRPCRouter } from '@atcute/xrpc-server';
5
5
import { parseDid } from '../util/api.js';
6
-
import { ResourceUri } from '@atcute/lexicons/syntax';
6
+
import { Handle, ResourceUri } from '@atcute/lexicons/syntax';
7
7
import { Logger } from 'pino';
8
8
import { isLegacyBlob } from '@atcute/lexicons/interfaces';
9
9
···
25
25
orderBy: recipeTable.createdAt,
26
26
limit: limit,
27
27
where: whereClauses ? and(...whereClauses) : undefined,
28
+
with: {
29
+
author: true,
30
+
},
28
31
});
32
+
33
+
console.log(recipes);
29
34
30
35
let nextCursor = '';
31
36
if (recipes.length == limit) {
···
37
42
nextCursor,
38
43
recipes: recipes.map((recipe) => ({
39
44
author: {
40
-
did: recipe.did,
45
+
did: recipe.author.did,
41
46
handle: 'hayden.moe',
42
-
createdAt: new Date().toISOString(),
47
+
displayName: recipe.author.displayName,
48
+
avatar: isLegacyBlob(recipe.author.avatarRef) ? undefined : recipe.author.avatarRef ?? undefined,
49
+
pronouns: recipe.author.pronouns ?? undefined,
50
+
createdAt: recipe.author.createdAt.toISOString(),
43
51
},
44
52
cid: '',
45
-
indexedAt: new Date().toISOString(),
53
+
indexedAt: recipe.ingestedAt.toISOString(),
46
54
record: {
47
55
$type: BlueRecipesFeedRecipe.mainSchema.object.shape.$type.expected,
48
56
title: recipe.title,
+5
-1
libs/database/lib/schema.ts
+5
-1
libs/database/lib/schema.ts
···
2
2
import { BlueRecipesFeedRecipe, BlueRecipesActorProfile } from "@cookware/lexicons";
3
3
import { isCid, ResourceUri, type AtprotoDid } from "@atcute/lexicons/syntax";
4
4
import { Blob, LegacyBlob } from "@atcute/lexicons";
5
-
import { sql, type SQL } from "drizzle-orm";
5
+
import { relations, sql, type SQL } from "drizzle-orm";
6
6
import { isBlob, isCidLink, isLegacyBlob } from "@atcute/lexicons/interfaces";
7
7
8
8
const dateIsoText = customType<{ data: Date; driverData: string }>({
···
103
103
index('recipes_iat_idx').on(t.ingestedAt),
104
104
primaryKey({ columns: [ t.did, t.rkey ] }),
105
105
]));
106
+
107
+
export const recipeTableRelations = relations(recipeTable, ({ one }) => ({
108
+
author: one(profilesTable, { fields: [recipeTable.did], references: [profilesTable.did] })
109
+
}));