Answer the question
In order to leave comments, you need to log in
How to process all requests directed to API Gateway through one Lambda function?
I created a lambda function which has code like this:
'use strict'
const { createServer, proxy } = require('aws-serverless-express')
const express = require('express')
const app = express()
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
app.get('/', (req, res) => {
res.send('ALOHA HONUA!')
})
app.get('/products', async (req, res) => {
res.send('Товары')
})
app.get('/categories', async (req, res) => {
res.send('Категории')
})
module.exports.handler = (event, ctx) => {
proxy(server, event, ctx)
}
Answer the question
In order to leave comments, you need to log in
In general, the aws-serverless-express package is no longer very relevant and turned out to be. It may have been configurable to make it work, but their npm page now points to a slightly different github repository.
It is enough to follow one of their examples, for example this one, and everything will work like clockwork.
It is very convenient for various kinds of knick-knacks, if you are too lazy to fool around with dockers / nginxes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question