Api Custom Function with routing

Screenshot from 2024-07-08 14-53-43

I would like to create /public/* path for pass kubernetis ingress. I will share public data by using that looks like /public/document-count. Or should i use something like

import type { APIGatewayProxyEvent, Context } from 'aws-lambda'
import { logger } from 'src/lib/logger'

export const handler = async (
  event: APIGatewayProxyEvent,
  _context: Context
) => {
  const path = event.path.replace('/public', '')
  switch (path) {
    case '/document-count':
      return documentCountHandler(event, _context)
      return {
        statusCode: 404,
        body: { message: `${path} Not Found` },

const documentCountHandler = (
  _event: APIGatewayProxyEvent,
  _context: Context
) => {}
1 Like

Hi @samimozcan!

Welcome to the community! You can definitely use a custom function like this, but an alternative may be to use a server-file to create a custom route, since you are deploying via Kubernetes.

See docs here:

Using the server-file will give you full access to the server we create, so you will be able to attach your own handlers. I don’t have a snippet handy, but please do post back here if this works for you :slight_smile: :v: