Skip to content

Question about Mockoon Serverless with data mocking #1170

Answered by 255kb
aravind52 asked this question in Help
Discussion options

You must be logged in to vote

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 …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aravind52
Comment options

Answer selected by aravind52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants