https://serverless-stack.com/ logo
#help
Title
# help
g

Gerald

11/02/2021, 12:41 PM
Hi, is there a way to do this in SST?
Copy code
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);
t

thdxr

11/02/2021, 12:42 PM
That should work in sst but I strongly recommend not using express with serverless
g

Gerald

11/02/2021, 12:45 PM
I understand. I am planning to migrate my express application to sst. Just in the meantime, that would I want to do first.
How can I export the express app in sst?
got it hehehehe!
the code above is working hehehe!
t

thdxr

11/02/2021, 1:31 PM
Ah gotcha
h

Haseeb Naseem

11/02/2021, 3:26 PM
@thdxr Curious to hear why you don’t recommend using express with serverless.
t

thdxr

11/02/2021, 3:27 PM
You can use it and it'll work fine but you're sort of avoiding embracing the actual serverless patterns and using CDK constructs to define your routes
There's benefits to having AWS be aware of that stuff for observability. Can also do schema validations there as well
Basically you're shipping express to do a bunch of work that AWS can already do for you