Skip to content

Instantly share code, notes, and snippets.

@viktorfa
Last active August 17, 2020 10:14
Show Gist options
  • Save viktorfa/3975ee2e67f38e885d02b4e2c4c1097e to your computer and use it in GitHub Desktop.
Save viktorfa/3975ee2e67f38e885d02b4e2c4c1097e to your computer and use it in GitHub Desktop.
// config/database.js
const getDatabaseConfig = ({ env }) => {
if (
env("IS_OFFLINE", null) === "true" ||
env("LAMBDA_RUNTIME_DIR", null) === null
) {
// In local simulated Lambda or normal Strapi
return {
connector: "mongoose",
settings: {
uri: env("MONGODB_URI"),
},
options: {
ssl: true,
},
};
} else {
// In Lambda on AWS
return {
connector: "mongoose",
settings: {
uri: env("MONGODB_URI"),
},
options: {
ssl: true,
},
};
}
};
module.exports = ({ env }) => ({
defaultConnection: "default",
connections: {
default: getDatabaseConfig({ env }),
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment