Add a Create Note API


#122

@benoram @jchastain Can you guys try running the command with the debug flag?

$ SLS_DEBUG=* serverless invoke local --function create --path mocks/create-event.json

#123

@jayair , i ran into the same issue as @benoram and jchastain on windows .

see logs with set SLS_debug=*.

The only other thing that i thought i will highlight when i did “npm install url” step. it showed 4 high vulnerable issues that i asked it to be fixed, Everything else looks right unless i (and others have done something silly)

D:\Learn\serverless\notes-app-api>serverless invoke local --function create --path mocks/create-event.json
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command webpack
Serverless: Load command offline
Serverless: Load command offline:start
Serverless: Invoke invoke:local
Serverless: Invoke webpack:validate
Serverless: Invoke webpack:compile
Serverless: Bundling with Webpack...
Time: 776ms
Built at: 11/29/2018 12:53:50 AM
        Asset      Size  Chunks             Chunk Names
    create.js  7.35 KiB  create  [emitted]  create
create.js.map   7.2 KiB  create  [emitted]  create
Entrypoint create = create.js create.js.map
[./create.js] 2.26 KiB {create} [built]
[aws-sdk] external "aws-sdk" 42 bytes {create} [built]
[babel-runtime/core-js/json/stringify] external "babel-runtime/core-js/json/stringify" 42 bytes {create} [built]
[source-map-support/register] external "source-map-support/register" 42 bytes {create} [built]
[uuid] external "uuid" 42 bytes {create} [built]
Serverless: INVOKING INVOKE
{}

  Error --------------------------------------------------

  Exception encountered when loading D:\Learn\serverless\notes-app-api\.webpack\service\create

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

Error: Exception encountered when loading D:\Learn\serverless\notes-app-api\.webpack\service\create
    at AwsInvokeLocal.invokeLocalNodeJs (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\invokeLocal\index.js:272:13)
    at AwsInvokeLocal.invokeLocal (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\invokeLocal\index.js:125:19)
From previous event:
    at Object.invoke:local:invoke [as hook] (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\invokeLocal\index.js:26:10)
    at BbPromise.reduce (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:390:55)
From previous event:
    at PluginManager.invoke (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:390:22)
    at PluginManager.run (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:421:17)
    at variables.populateService.then.then (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:157:33)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
    at Serverless.run (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:144:8)
    at serverless.init.then (C:\Users\d372426\AppData\Roaming\npm\node_modules\serverless\bin\serverless:43:50)

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

  Your Environment Information -----------------------------
     OS:                     win32
     Node Version:           10.13.0
     Serverless Version:     1.32.0

#124

like others refactoring the code fixed it. Still wondering what the problem was ? Wondering if import of aws-sdk in create.js was creating a conflict with webpack !


#125

I have the same issue and you and other say that refactoring works.
However, I have no idea what you mean by this.


#126

Continue with next steps where the author introduces lib , asks to re write create.js.


#127

Allright, I though you guys where doing something in your editors (there is for instance a “refactor” command in VisualStudio Code). I guess the problem is with the function callback(null,params) ? What is the definition of callback?


#128

@ravin018 Thanks for trying to debug it. I don’t know if it’s the aws-sdk because all we did was move it around. But I’ll try it out and see what is going on.

@KDkeml Here is some more info on the callback function.

https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html


#129

I re-ran through from the beginning, and this time it worked. The only difference I’m aware of between the 1st and 2nd tries is that the first time I ran an npm audit fix, the second time I did not.


#130

Hi,

Thanks for the great tutorial!

I have no response wit the call.

With the debug I’ve got this…

SLS_DEBUG=* sls invoke local --function create --path mocks/create-event.json 

Serverless: Load command config

Serverless: Load command config:credentials

Serverless: Load command create

Serverless: Load command install

Serverless: Load command package

Serverless: Load command deploy

Serverless: Load command deploy:function

Serverless: Load command deploy:list

Serverless: Load command deploy:list:functions

Serverless: Load command invoke

Serverless: Load command invoke:local

Serverless: Load command info

Serverless: Load command logs

Serverless: Load command login

Serverless: Load command logout

Serverless: Load command metrics

Serverless: Load command print

Serverless: Load command remove

Serverless: Load command rollback

Serverless: Load command rollback:function

Serverless: Load command slstats

Serverless: Load command plugin

Serverless: Load command plugin

Serverless: Load command plugin:install

Serverless: Load command plugin

Serverless: Load command plugin:uninstall

Serverless: Load command plugin

Serverless: Load command plugin:list

Serverless: Load command plugin

Serverless: Load command plugin:search

Serverless: Load command config

Serverless: Load command config:credentials

Serverless: Load command rollback

Serverless: Load command rollback:function

Serverless: Load command webpack

Serverless: Load command offline

Serverless: Load command offline:start

Serverless: Invoke invoke:local

Serverless: Invoke webpack:validate

Serverless: Invoke webpack:compile

Serverless: Bundling with Webpack...

Time: 419ms

Built at: 2018-12-07 16:12:13

Asset Size Chunks Chunk Names

create.js 7.42 KiB create [emitted] create

create.js.map 7.14 KiB create [emitted] create

Entrypoint create = create.js create.js.map

[./create.js] 2.33 KiB {create} [built]

[aws-sdk] external "aws-sdk" 42 bytes {create} [built]

[babel-runtime/core-js/json/stringify] external "babel-runtime/core-js/json/stringify" 42 bytes {create} [built]

[source-map-support/register] external "source-map-support/register" 42 bytes {create} [built]

[uuid] external "uuid" 42 bytes {create} [built]

Any idea?


#131

Did you try the suggestion that the others had? Try completing the chapter and seeing if it fixes it?

Edit:

I tried out the steps with Serverless Framework version 1.34.1 and it seemed fine. Which version are you using?


#132

Thanks @jayair, my versions were outdated… with this versions everything works as expected…

  • npm 6.4.1
  • node v11.4.0
  • sls 1.34.1

#133

Great! Thanks for reporting back.