-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate feeds worker to next api (#4021)
- Loading branch information
Showing
30 changed files
with
62 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { AlgorithmProvider } from '@hey/data/enums'; | ||
import { Errors } from '@hey/data/errors'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import allowCors from 'utils/allowCors'; | ||
import { CACHE_AGE } from 'utils/constants'; | ||
import heyFeed from 'utils/feeds/providers/hey/heyFeed'; | ||
import k3lFeed from 'utils/feeds/providers/k3l/k3lFeed'; | ||
|
||
const handler = async (req: NextApiRequest, res: NextApiResponse) => { | ||
const provider = req.query.provider as string; | ||
const strategy = req.query.strategy as string; | ||
const profile = req.query.profile as string; | ||
const limit = (parseInt(req.query?.limit as string) || 50) as number; | ||
const offset = (parseInt(req.query?.offset as string) || 0) as number; | ||
|
||
if (!provider || !strategy) { | ||
return res.status(400).json({ success: false, error: Errors.NoBody }); | ||
} | ||
|
||
try { | ||
let ids: string[] = []; | ||
switch (provider) { | ||
case AlgorithmProvider.K3L: | ||
ids = await k3lFeed(strategy, profile, limit, offset); | ||
break; | ||
case AlgorithmProvider.HEY: | ||
ids = await heyFeed(strategy, limit, offset); | ||
break; | ||
default: | ||
return res | ||
.status(200) | ||
.setHeader('Cache-Control', CACHE_AGE) | ||
.json({ success: false, message: 'Invalid provider' }); | ||
} | ||
|
||
return res | ||
.status(200) | ||
.setHeader('Cache-Control', CACHE_AGE) | ||
.json({ success: true, ids }); | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; | ||
|
||
export default allowCors(handler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 5 additions & 11 deletions
16
...providers/hey/algorithms/heyMostViewed.ts → ...providers/hey/algorithms/heyMostViewed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 3 additions & 9 deletions
12
...orkers/feeds/src/providers/hey/heyFeed.ts → .../api/utils/feeds/providers/hey/heyFeed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...providers/k3l/algorithms/k3lGlobalFeed.ts → ...providers/k3l/algorithms/k3lGlobalFeed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...oviders/k3l/algorithms/k3lPersonalFeed.ts → ...oviders/k3l/algorithms/k3lPersonalFeed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
packages/workers/feeds/src/handlers/getPublicationIds.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
ab81314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
prerender – ./apps/prerender
prerender-git-main-heyxyz.vercel.app
prerender.hey.xyz
prerender-heyxyz.vercel.app
ab81314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
api – ./apps/api
api-git-main-heyxyz.vercel.app
hey-api.vercel.app
api-heyxyz.vercel.app
api.hey.xyz
ab81314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web – ./apps/web
web-git-main-heyxyz.vercel.app
web-heyxyz.vercel.app
heyxyz.vercel.app
hey.xyz