-
Does mockoon serverless for AWS Lambda support multiple JSON data files. As you see below, I am able to run 2 servers on different ports while running CLI. I am trying to achieve the same thing using Mockoon Serverless for AWS Lambda. mockoon-cli start --data <filename1.json> <filename2.json> Any help would be greatly appreciated |
Beta Was this translation helpful? Give feedback.
Answered by
255kb
Oct 26, 2023
Replies: 1 comment 1 reply
-
Something like this should work: const mockoon = require("@mockoon/serverless");
const express = require("express")();
const serverlessHttp = require("serverless-http");
// Load the Mockoon Environment object
const mockEnv1 = require("./datafile1.json");
const mockEnv2 = require("./datafile2.json");
const app1 = new mockoon.MockoonServerless(mockEnv1);
const app2 = new mockoon.MockoonServerless(mockEnv2);
express.use('/api1',app1.requestListener());
express.use('/api2',app2.requestListener());
// can't use app1 or app2 awsHandler() as we need to expose the new express app
module.exports.handler = serverlessHttp(express); You could also use this approach to differenciate which app to use depending on other request params than the path. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
aravind52
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Something like this should work:
You could also use this approach to differenciate which app to …