MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / handler

Function handler

apps/web/pages/api/mentions/index.ts:7–39  ·  view source on GitHub ↗
(
  request: NextApiRequest,
  response: NextApiResponse
)

Source from the content-addressed store, hash-verified

5import { cors, preflight } from 'utilities/cors';
6
7export default async function handler(
8 request: NextApiRequest,
9 response: NextApiResponse
10) {
11 if (request.method === 'OPTIONS') {
12 return preflight(request, response, ['GET']);
13 }
14 cors(request, response);
15
16 if (!request.query.communityId) {
17 return response.status(400).end();
18 }
19 const permissions = await PermissionsService.get({
20 request,
21 response,
22 params: {
23 communityId: request.query.communityId as string,
24 },
25 });
26
27 if (!permissions.is_member) {
28 return response.status(403).end();
29 }
30
31 if (request.method === 'GET') {
32 const term = request.query.term as string;
33 const users = await getMentions(term, request.query.communityId as string);
34 response.status(200).json(users.map(serializeUser));
35 return response.end();
36 }
37
38 return response.status(405).end();
39}
40
41async function getMentions(term: string, accountId: string) {
42 const condition = term

Callers

nothing calls this directly

Calls 6

preflightFunction · 0.90
corsFunction · 0.90
mapMethod · 0.80
getMentionsFunction · 0.70
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected