Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpApi does not work with template aws-nodejs-typescript #999

Closed
ilievski-david opened this issue Jun 1, 2020 · 1 comment · Fixed by #1000
Closed

HttpApi does not work with template aws-nodejs-typescript #999

ilievski-david opened this issue Jun 1, 2020 · 1 comment · Fixed by #1000
Assignees
Labels

Comments

@ilievski-david
Copy link

ilievski-david commented Jun 1, 2020

Bug Report

Current behavior
Using the default typescript template aws-node-js template with httpApi serverless offline gives the following error:

 Type Error ---------------------------------------------

  TypeError: Cannot read property 'startsWith' of undefined
      at generateHapiPath (C:\Users\iliev\OneDrive\Documents\Projects\TukaSum\Kod\Lambda\TukaSum-Lambda\Lambda-Functions\source\create-post\node_modules\serverless-offline\dist\utils\generateHapiPath.js:10:23)
      at HttpServer.createRoutes (C:\Users\iliev\OneDrive\Documents\Projects\TukaSum\Kod\Lambda\TukaSum-Lambda\Lambda-Functions\source\create-post\node_modules\serverless-offline\dist\events\http\HttpServer.js:264:51)
      at Http._create (C:\Users\iliev\OneDrive\Documents\Projects\TukaSum\Kod\Lambda\TukaSum-Lambda\Lambda-Functions\source\create-post\node_modules\serverless-offline\dist\events\http\Http.js:41:65)
      at C:\Users\iliev\OneDrive\Documents\Projects\TukaSum\Kod\Lambda\TukaSum-Lambda\Lambda-Functions\source\create-post\node_modules\serverless-offline\dist\events\http\Http.js:50:12
      at Array.forEach (<anonymous>)
      at Http.create (C:\Users\iliev\OneDrive\Documents\Projects\TukaSum\Kod\Lambda\TukaSum-Lambda\Lambda-Functions\source\create-post\node_modules\serverless-offline\dist\events\http\Http.js:45:12)
      at ServerlessOffline._createHttp (C:\Users\iliev\OneDrive\Documents\Projects\TukaSum\Kod\Lambda\TukaSum-Lambda\Lambda-Functions\source\create-post\node_modules\serverless-offline\dist\ServerlessOffline.js:216:53)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at async Promise.all (index 0)
      at ServerlessOffline.start (C:\Users\iliev\OneDrive\Documents\Projects\TukaSum\Kod\Lambda\TukaSum-Lambda\Lambda-Functions\source\create-post\node_modules\serverless-offline\dist\ServerlessOffline.js:131:5)
      at ServerlessOffline._startWithExplicitEnd (C:\Users\iliev\OneDrive\Documents\Projects\TukaSum\Kod\Lambda\TukaSum-Lambda\Lambda-Functions\source\create-post\node_modules\serverless-offline\dist\ServerlessOffline.js:180:5)
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              12.16.2
     Framework Version:         1.71.3
     Plugin Version:            3.6.12
     SDK Version:               2.3.1
     Components Version:        2.30.11

Sample code

  • serverless.yaml
    note: the only change is from http to httpApi
service:
  name: serverless
# app and org for use with dashboard.serverless.com
#app: your-app-name
#org: your-org-name

custom:
  webpack:
    webpackConfig: ./webpack.config.js
    includeModules: true

# Add the serverless-webpack plugin
plugins:
  - serverless-webpack
  - serverless-offline

  

provider:
  name: aws
  runtime: nodejs12.x
  apiGateway:
    minimumCompressionSize: 1024 # Enable gzip compression for responses > 1 KB
  environment:
    AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1

functions:
  hello:
    handler: handler.hello
    events:
      - httpApi: "*"

  • handler.ts
import { APIGatewayProxyHandler } from 'aws-lambda';
import 'source-map-support/register';

export const hello: APIGatewayProxyHandler = async (event, _context) => {
  return {
    statusCode: 200,
    body: JSON.stringify({
      message: 'Go Serverless Webpack (Typescript) v1.0! Your function executed successfully!',
      input: event,
    }, null, 2),
  };
}

Environment

  • serverless version: 1.71.3
  • serverless offline version: 6.3.0
  • node version: 12.16.2
  • os : windows 10
@chardos
Copy link
Collaborator

chardos commented Jun 2, 2020

Thanks @id-997, I will look into this shortly.

@chardos chardos linked a pull request Jun 2, 2020 that will close this issue
@chardos chardos self-assigned this Jun 2, 2020
@chardos chardos added the bug label Jun 2, 2020
@chardos chardos changed the title HttpAPi does not work with template aws-nodejs-typesctript HttpApi does not work with template aws-nodejs-typescript Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants