Guest User

Untitled

a guest
Jan 3rd, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. import { APIGatewayEvent, Callback, Context, Handler } from 'aws-lambda';
  2. import { Column, Model, PrimaryKey, Sequelize , Table } from 'sequelize-typescript';
  3.  
  4. @Table
  5. class SomeModel extends Model<SomeModel> {
  6. @Column
  7. @PrimaryKey
  8. public id: number;
  9. }
  10.  
  11. export const handler: Handler = (event: APIGatewayEvent, context: Context, cb: Callback) => {
  12. const sequelize = new Sequelize({
  13. host: '...',
  14. database: '...',
  15. dialect: 'mssql',
  16. username: '...',
  17. password: '...',
  18. });
  19.  
  20. sequelize.addModels([SomeModel]);
  21.  
  22. sequelize.authenticate()
  23. .then(() => {
  24. console.log('Connection has been established successfully.');
  25.  
  26. const dbversion = sequelize.options.databaseVersion;
  27. const response = {
  28. statusCode: 200,
  29. body: JSON.stringify('DB version: ' + dbversion),
  30. };
  31. cb(null, response);
  32. })
  33. .catch(err => {
  34. console.error('Unable to connect to the database:', err);
  35. });
  36. };
  37.  
  38. {}
  39.  
  40. Error --------------------------------------------------
  41.  
  42. Exception encountered when loading C:UsersThomasDocumentsGitHubTest.webpackservicefunctionsdbtestget-dbtest
  43.  
  44. For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
  45.  
  46. Stack Trace --------------------------------------------
  47.  
  48. Error: Exception encountered when loading C:UsersThomasDocumentsGitHubTest.webpackservicefunctionsdbtestget-dbtest
  49. at AwsInvokeLocal.invokeLocalNodeJs (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibpluginsawsinvokeLocalindex.js:307:13)
  50. at AwsInvokeLocal.invokeLocal (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibpluginsawsinvokeLocalindex.js:131:19)
  51. From previous event:
  52. at Object.invoke:local:invoke [as hook] (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibpluginsawsinvokeLocalindex.js:27:10)
  53. at BbPromise.reduce (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:391:55)
  54. From previous event:
  55. at PluginManager.invoke (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:391:22)
  56. at PluginManager.run (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:422:17)
  57. at variables.populateService.then.then (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibServerless.js:157:33)
  58. at runCallback (timers.js:794:20)
  59. at tryOnImmediate (timers.js:752:5)
  60. at processImmediate [as _immediateCallback] (timers.js:729:5)
  61. From previous event:
  62. at Serverless.run (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibServerless.js:144:8)
  63. at serverless.init.then (C:UsersThomasAppDataRoamingnpmnode_modulesserverlessbinserverless:44:28)
  64. at <anonymous>
  65.  
  66. Get Support --------------------------------------------
  67. Docs: docs.serverless.com
  68. Bugs: github.com/serverless/serverless/issues
  69. Issues: forum.serverless.com
  70.  
  71. Your Environment Information -----------------------------
  72. OS: win32
  73. Node Version: 8.10.0
  74. Serverless Version: 1.35.1
Add Comment
Please, Sign In to add comment