Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function runAppSyncSimulator(config, port?: number, wsPort?: number) {
const appsyncSimulator = new AmplifyAppSyncSimulator({ port, wsPort });
await appsyncSimulator.start();
await appsyncSimulator.init(config);
return appsyncSimulator;
}
async start(context, port: number = 20002, wsPort: number = 20003) {
try {
addCleanupTask(context, async context => {
await this.stop(context);
});
this.projectRoot = context.amplify.getEnvInfo().projectPath;
this.configOverrideManager = ConfigOverrideManager.getInstance(context);
this.apiName = await this.getAppSyncAPI(context);
this.ddbClient = await this.startDynamoDBLocalServer(context);
const resolverDirectory = await this.getResolverTemplateDirectory(context);
this.resolverOverrideManager = new ResolverOverrides(resolverDirectory);
this.appSyncSimulator = new AmplifyAppSyncSimulator({
port,
wsPort,
});
await this.appSyncSimulator.start();
await this.resolverOverrideManager.start();
await this.watch(context);
const appSyncConfig: AmplifyAppSyncSimulatorConfig = await this.runTransformer(context);
this.appSyncSimulator.init(appSyncConfig);
await this.generateTestFrontendExports(context);
await this.generateCode(context);
context.print.info(`AppSync Mock endpoint is running at ${this.appSyncSimulator.url}`);
} catch (e) {
context.print.error(`Failed to start API Mock endpoint ${e}`);
}