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

Function handler

apps/web/pages/api/user-thread-status/index.ts:115–148  ·  view source on GitHub ↗
(
  request: NextApiRequest,
  response: NextApiResponse
)

Source from the content-addressed store, hash-verified

113}
114
115export default async function handler(
116 request: NextApiRequest,
117 response: NextApiResponse
118) {
119 if (request.method === 'OPTIONS') {
120 return preflight(request, response, ['POST']);
121 }
122 cors(request, response);
123
124 if (request.method === 'POST') {
125 const permissions = await PermissionsService.get({
126 request,
127 response,
128 params: {
129 communityId: request.body.communityId,
130 },
131 });
132 if (!permissions.access) {
133 return response.status(401).json({});
134 }
135
136 if (!permissions.user) {
137 return response.status(401).json({});
138 }
139
140 const { status, data } = await create({
141 ...request.body,
142 communityId: request.body.communityId,
143 userId: permissions.user.id,
144 });
145 return response.status(status).json(data || {});
146 }
147 return response.status(405).json({});
148}

Callers

nothing calls this directly

Calls 4

preflightFunction · 0.90
corsFunction · 0.90
createFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected