juanjoDiaz / serverless-middleware

Serverless plugin to allow middleware handlers configured directly in serverless.yaml
MIT License
18 stars 11 forks source link

I can't setup serverless middleware #55

Open salamat9 opened 8 months ago

salamat9 commented 8 months ago

I have function

getCategories:
    middleware:
      pre:
        - ./src/middleware/auth.middleware
    handler: ./src/handlers/categories/getAll.handler
    events:
      - http:
          path: /api/categories
          method: GET
          cors: true

src/middleware/auth.ts

export const middleware = async (event: any, context: any) => {
    try {
        console.log("hello from auth middleware");
        console.log(event);
        console.log(context);
    } catch (err) {
        console.log(err);
    }
};

when i trigger my function it ignores the middleware

juanjoDiaz commented 7 months ago

Hi @salamat9 ,

How are you triggering your function?

Did you check the code that was publish to AWS? Did it include the middleware?