1

I have a Nodejs express app using Mongodb, and I want to go serverless.

Do I have to write again all my endpoints express with aws Lambda ? How can I convert my mongoose schemas to work with Dynamodb ?

I tried to use aws codestar service and found that I can use Express.js but just as a web service. I still don't understand why I can't use it with a web application.

I Need some clarification, please.

Thanks in advance.

user3711521
  • 285
  • 5
  • 14

1 Answers1

2

if you need to convert your express.js app to serverless. You can use serverless framework and serverless-http module.

add serverless-http moduele to app

npm install --save express serverless-http

Then modify your app this way

const serverless = require('serverless-http');
const express = require('express')
const app = express()

app.get('/', function (req, res) {
  res.send('Hello World!')
})

module.exports.handler = serverless(app)

More details read this article .

You can't use mongoose for dynamodb. try to use dynamoose

Niroshan Ranapathi
  • 3,007
  • 1
  • 25
  • 35