examples icon indicating copy to clipboard operation
examples copied to clipboard

aws-node-rest-api-typescript: Add Mongo/Atlas connection instructions

Open lukesdm opened this issue 4 years ago • 1 comments

Following the instructions in README.md on running the app you will see {"message": "Internal server error"}

And a stack trace resembling

 MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
      at NativeConnection.Connection.openUri (C:\Users\luke\src\luke-typescript-rest-api-app\node_modules\mongoose\lib\connection.js:693:11)
      at C:\Users\luke\src\luke-typescript-rest-api-app\node_modules\mongoose\lib\index.js:345:10
      at C:\Users\luke\src\luke-typescript-rest-api-app\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:5

I think this is because the Mongo/Atlas connection strings need to be set first. Would be handy to have how to do this in the readme.

lukesdm avatar Feb 17 '21 18:02 lukesdm

I can confirm adding MongoDB Atlas connection details fixed the internal server error. These additional steps are needed:

  1. Set up a MongoDB Atlas DB + user, and make it accessible to AWS IPs as appropriate. (details omitted, probably better explained in an external doc).
  2. Add parameters to runtime environment in the serverless.yml file, e.g. image
  3. In the serverless dashboard, add the parameters for the chosen environment, e.g. image
  4. run serverless deploy again

lukesdm avatar Feb 18 '21 09:02 lukesdm