--

You can write a async function, where you can put all startup codes snippet and make sure you load env variables at very top. You can take reference of below code snippet

```

const express = require('express');

app = express();

async function main() {

// await to load env variables from secret manager

app.listen(PORT, () => { console.log('server started') });

}

main().catch(err => { throw err; })

```

I have not checked syntax of above code. But hope this solve your problem.

--

--

Ajay Kumar Pandit
Ajay Kumar Pandit

Written by Ajay Kumar Pandit

A passionate Software Engineer who writes on latest tech and trends. Subscribe to stay updated https://www.youtube.com/@codingwithkrpajay?sub_confirmation=1

No responses yet