UNPKG

@seasketch/geoprocessing

Version:

Geoprocessing and reporting framework for SeaSketch 2.0

63 lines 2.6 kB
import { Function, Code } from "aws-cdk-lib/aws-lambda"; import config from "./config.js"; import path from "node:path"; /** * Create Lambda function constructs core to project */ export const createProjectFunctions = (stack) => { return { serviceRootFunction: createRootFunction(stack), socketFunctions: createSocketFunctions(stack), }; }; const createRootFunction = (stack) => { return new Function(stack, "GpServiceRootFunction", { runtime: config.NODE_RUNTIME, code: Code.fromAsset(path.join(stack.props.projectPath, ".build", "serviceHandlers")), functionName: `gp-${stack.props.projectName}-metadata`, handler: "serviceHandlers.projectMetadata", }); }; export const createSocketFunctions = (stack) => { let socketFunctions = { subscribe: undefined, unsubscribe: undefined, send: undefined, }; if (stack.hasAsyncFunctions()) { const subscribe = new Function(stack, "GpSubscribeHandler", { runtime: config.NODE_RUNTIME, code: Code.fromAsset(path.join(stack.props.projectPath, ".build", "connect")), handler: "connect.connectHandler", functionName: `gp-${stack.props.projectName}-subscribe`, memorySize: config.SOCKET_HANDLER_MEMORY, timeout: config.SOCKET_HANDLER_TIMEOUT, description: "Subscribe to messages", }); const unsubscribe = new Function(stack, "GpUnsubscribeHandler", { runtime: config.NODE_RUNTIME, code: Code.fromAsset(path.join(stack.props.projectPath, ".build", "disconnect")), handler: "disconnect.disconnectHandler", functionName: `gp-${stack.props.projectName}-unsubscribe`, memorySize: config.SOCKET_HANDLER_MEMORY, timeout: config.SOCKET_HANDLER_TIMEOUT, description: "Unsubscribe from messages", }); const send = new Function(stack, "GpSendHandler", { runtime: config.NODE_RUNTIME, code: Code.fromAsset(path.join(stack.props.projectPath, ".build", "sendmessage")), handler: "sendmessage.sendHandler", functionName: `gp-${stack.props.projectName}-send`, memorySize: config.SOCKET_HANDLER_MEMORY, timeout: config.SOCKET_HANDLER_TIMEOUT, description: " for sending messages on sockets", }); socketFunctions = { subscribe, unsubscribe, send, }; } return socketFunctions; }; //# sourceMappingURL=functionResources.js.map