SKILL.md
Add API Endpoint
Create endpoint for $ARGUMENTS.
Steps
- Read the pattern: Open
packages/server/api/src/app/tables/table/table.controller.tsas reference.
- Create or update controller using
FastifyPluginAsyncZod:
``typescript export const myController: FastifyPluginAsyncZod = async (fastify) => { fastify.post('/', CreateRequest, async (request) => { return myService(request.log).create({ projectId: request.projectId, request: request.body, }) }) } ``
- Define route config AFTER the controller (not inline):
``typescript const CreateRequest = { config: { security: securityAccess.project( [PrincipalType.USER, PrincipalType.ENGINE, PrincipalType.SERVICE], Permission.WRITEMYFEATURE, { type: ProjectResourceType.BODY }, ), }, schema: { tags: ['my-feature'], body: CreateMyFeatureRequest, // Zod schema from @activepieces/shared response: { [StatusCodes.CREATED]: MyFeature }, }, } ``
- Security access (pick one):
- securityAccess.project(principals, permission, { type: ProjectResourceType.X }) — project-scoped - securityAccess.platformAdminOnly(principals) — admin only - securityAccess.publicPlatform(principals) — any platform member - securityAccess.public() — no auth
- Create module and register in
app.ts:
``typescript export const myModule: FastifyPluginAsyncZod = async (app) => { app.addHook('preSerialization', entitiesMustBeOwnedByCurrentProject) await app.register(myController, { prefix: '/v1/my-features' }) } ``
- Add Permission if new: add to
Permissionenum in@activepieces/shared.
- Verify:
npm run lint-dev