juanjoDiaz/serverless-middleware

Not working with typescript: handler as string error

Closed this issue · 1 comments

Hi,
I am getting an error when adding the middleware as a handler array in my function.
I am using typescript therefore my serverless file is a typescript file instead of yml:

Cannot load "serverless.ts": Initialization error: TSError:  Unable to compile TypeScript:
serverless.ts:45:4 - error TS2322: Type 'string[]' is not assignable to type 'string'.
functions: {
  index: {
	  handler: [
		  'lambdas/endpoints/common/middleware.publicAuth', 
		  'lambdas/endpoints/common/default.index'],
	  events: [{
		  http: {
			  method: 'get',
			  path: '',
		  }
	  }]
  },

I am doing something wrong?
Thanks!

No. Typescript is just more strict than javascript.

Next version fo this library will use middlewares instead of handler solving this issue.