I’m need get database credentials from Amazon Aws Secrets in a async call, but the database.ts file is syncronous so an error occur when Strapi try to connect in database:
Error: Unknown dialect undefined
So my question is: How to connect in database with async credentials?
Hello you can use register function from src/index.js. Register function is an async function.
Install aws-sdk. Call secret manager and inject credentials on strapi.config object.
Example :
Thanks Glenn, thats a very usefult answer you provided.
For anyone whos is till confused, please write an async function in default register method in index.js in src folder for strapi v4
To connect to the database with async credentials, you’ll need to adjust your databases file to handle asynchronous operations. Instead of synchronous retrieval, utilize async/await syntax to fetch credentials from Amazon AWS Secrets Manager. Ensure robust error handling to address any issues during credential retrieval. Test thoroughly to verify the updated setup’s functionality. This approach should allow you to connect to the database without encountering the “Unknown dialect undefined” error. If you encounter any challenges, don’t hesitate to seek assistance.