Skip to content

Commit

Permalink
Downgraded serverless express
Browse files Browse the repository at this point in the history
  • Loading branch information
jzongker committed Jul 1, 2024
1 parent 2ffdad3 commit 9c0846e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 27 deletions.
29 changes: 13 additions & 16 deletions lambda.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
const serverlessExpress = require('@codegenie/serverless-express')
const { init } = require('./dist/App');
const { createServer, proxy } = require('aws-serverless-express');
const { init } = require('./dist/app');
const { Pool } = require('@churchapps/apihelper');
const { Environment } = require('./dist/helpers/Environment');

let cachedServer;

const checkPool = async () => {
if (!Environment.connectionString) {
await Environment.init(process.env.APP_ENV);
await Environment.init(process.env.APP_ENV)
Pool.initPool();
}
};
}

async function setup (event, context) {
await checkPool();
const app = await init();
cachedServer = serverlessExpress({ app })
return cachedServer(event, context)
};
const universal = function universal(event, context) {
checkPool().then(() => {
init().then(app => {
const server = createServer(app);
return proxy(server, event, context);
});
});
}

module.exports.universal = function universal(event, context) {
if (cachedServer) return cachedServer(event, context)
return setup(event, context)
}
module.exports.universal = universal;
58 changes: 48 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"author": "Live Church Solutions",
"dependencies": {
"@churchapps/apihelper": "0.0.15",
"@codegenie/serverless-express": "^4.14.1",
"aws-serverless-express": "^3.4.0",
"@hubspot/api-client": "^11.1.0",
"axios": "^1.7.2",
"bcryptjs": "^2.4.3",
Expand Down

0 comments on commit 9c0846e

Please sign in to comment.