Menu

Five reads in our app write to the database, and one of them fetches a logo off the open web after the response has been sent
📰

Five reads in our app write to the database, and one of them fetches a logo off the open web after the response has been sent

DEV Community: react·Daniel Pertu·10 days ago
#LVtORPo2
#devtoreact#devto#dev#campaigns#null
Reading 0:00
15s threshold

Rendering a page should not change anything. Nakodo breaks that rule in five places, and every one of them is on purpose, so I went and wrote down the rule they actually follow.

The app runs outreach campaigns for brands: it finds creators or local businesses that fit a brief, writes to them, and hands over the ones that say yes, which is the bit described on how it works . Every page in this post is behind the login, which turns out to be half the reason the pattern is safe.

One: the first page you load creates your account row

export const requireUser = cache ( async (): Promise < SessionUser > => { const user = await getUser (); if ( ! user ) redirect ( " /login " ); if ( ! ( await getProfile ( user . id ))) await db . insert ( profiles ). values ({ id : user . id }). onConflictDoNothing (); return user ; });

Enter fullscreen mode

Exit fullscreen mode

Sign-up creates a profile row.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.