user3711521
user3711521

Reputation: 305

Converting an existing Nodejs Express application to a aws serverless App

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.

Upvotes: 2

Views: 1665

Answers (1)

Niroshan Ranapathi
Niroshan Ranapathi

Reputation: 3047

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

Upvotes: 2

Related Questions