MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / handler

Function handler

apps/web/pages/api/sync.ts:6–36  ·  view source on GitHub ↗
(request: NextApiRequest, response: NextApiResponse)

Source from the content-addressed store, hash-verified

4import { cors, preflight } from 'utilities/cors';
5
6async function handler(request: NextApiRequest, response: NextApiResponse) {
7 if (request.method === 'OPTIONS') {
8 return preflight(request, response, ['GET']);
9 }
10 cors(request, response);
11
12 if (!request.query.account_id) {
13 return response.status(400).json({});
14 }
15
16 const permissions = await PermissionsService.get({
17 request,
18 response,
19 params: {
20 communityId: request.query.account_id as string,
21 },
22 });
23 if (!permissions.manage) {
24 return response.status(401).json({});
25 }
26
27 const accountId = request.query.account_id as string;
28 const fileLocation = request.query.file_location as string | undefined;
29
30 await createSyncJob({
31 account_id: accountId,
32 file_location: fileLocation,
33 });
34
35 return response.status(200).json({});
36}
37
38export default handler;

Callers 1

auth.test.tsFile · 0.50

Calls 4

preflightFunction · 0.90
corsFunction · 0.90
createSyncJobFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected