Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { APIGatewayEvent, Callback, Context, Handler } from 'aws-lambda';
- import { Column, Model, PrimaryKey, Sequelize , Table } from 'sequelize-typescript';
- @Table
- class SomeModel extends Model<SomeModel> {
- @Column
- @PrimaryKey
- public id: number;
- }
- export const handler: Handler = (event: APIGatewayEvent, context: Context, cb: Callback) => {
- const sequelize = new Sequelize({
- host: '...',
- database: '...',
- dialect: 'mssql',
- username: '...',
- password: '...',
- });
- sequelize.addModels([SomeModel]);
- sequelize.authenticate()
- .then(() => {
- console.log('Connection has been established successfully.');
- const dbversion = sequelize.options.databaseVersion;
- const response = {
- statusCode: 200,
- body: JSON.stringify('DB version: ' + dbversion),
- };
- cb(null, response);
- })
- .catch(err => {
- console.error('Unable to connect to the database:', err);
- });
- };
- {}
- Error --------------------------------------------------
- Exception encountered when loading C:UsersThomasDocumentsGitHubTest.webpackservicefunctionsdbtestget-dbtest
- For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
- Stack Trace --------------------------------------------
- Error: Exception encountered when loading C:UsersThomasDocumentsGitHubTest.webpackservicefunctionsdbtestget-dbtest
- at AwsInvokeLocal.invokeLocalNodeJs (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibpluginsawsinvokeLocalindex.js:307:13)
- at AwsInvokeLocal.invokeLocal (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibpluginsawsinvokeLocalindex.js:131:19)
- From previous event:
- at Object.invoke:local:invoke [as hook] (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibpluginsawsinvokeLocalindex.js:27:10)
- at BbPromise.reduce (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:391:55)
- From previous event:
- at PluginManager.invoke (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:391:22)
- at PluginManager.run (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:422:17)
- at variables.populateService.then.then (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibServerless.js:157:33)
- at runCallback (timers.js:794:20)
- at tryOnImmediate (timers.js:752:5)
- at processImmediate [as _immediateCallback] (timers.js:729:5)
- From previous event:
- at Serverless.run (C:UsersThomasAppDataRoamingnpmnode_modulesserverlesslibServerless.js:144:8)
- at serverless.init.then (C:UsersThomasAppDataRoamingnpmnode_modulesserverlessbinserverless:44:28)
- at <anonymous>
- Get Support --------------------------------------------
- Docs: docs.serverless.com
- Bugs: github.com/serverless/serverless/issues
- Issues: forum.serverless.com
- Your Environment Information -----------------------------
- OS: win32
- Node Version: 8.10.0
- Serverless Version: 1.35.1
Add Comment
Please, Sign In to add comment