MCPcopy Create free account
hub / github.com/dailydotdev/apps / classifyProfileRequest

Function classifyProfileRequest

packages/shared/src/lib/user.ts:263–291  ·  view source on GitHub ↗
(
  status: number,
  response?: ProfileRequestResponse,
)

Source from the content-addressed store, hash-verified

261const profileNotFoundErrorCodes = new Set(['FORBIDDEN', 'NOT_FOUND']);
262
263export const classifyProfileRequest = (
264 status: number,
265 response?: ProfileRequestResponse,
266): ProfileRequestResult => {
267 if (status === 404) {
268 return { status: 'notFound' };
269 }
270
271 if (status >= 400) {
272 return {
273 status: 'failed',
274 error: new Error(`Failed to fetch profile: ${status}`),
275 };
276 }
277
278 if (response?.data?.user) {
279 return { status: 'found', user: response.data.user };
280 }
281
282 const errorCode = response?.errors?.[0]?.extensions?.code;
283 if (errorCode && profileNotFoundErrorCodes.has(errorCode)) {
284 return { status: 'notFound' };
285 }
286
287 return {
288 status: 'failed',
289 error: new Error('Failed to fetch profile'),
290 };
291};
292
293const getProfileRequest = async (id: string): Promise<ProfileRequestResult> => {
294 const userRes = await fetch(graphqlUrl, {

Callers 2

user.spec.tsFile · 0.90
getProfileRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected