mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
Route updates
This commit is contained in:
@@ -20,11 +20,13 @@ const DeployRequestSchema = z.object({
|
||||
region: z.string().min(1, 'AWS Region is required'),
|
||||
functionName: z.string().min(1, 'Function name is required'),
|
||||
handler: z.string().optional(),
|
||||
runtime: z.string().min(1, 'Runtime is required'),
|
||||
code: z.record(z.string()).refine((val) => Object.keys(val).length > 0, 'At least one code file is required'),
|
||||
runtime: z.string().min(1, 'Runtime is required').optional().default('nodejs18.x'),
|
||||
code: z
|
||||
.record(z.string())
|
||||
.refine((val) => Object.keys(val).length > 0, 'At least one code file is required'),
|
||||
requirements: z.string().nullable().optional(),
|
||||
packageJson: z.string().nullable().optional(),
|
||||
timeout: z.number().min(1).max(900),
|
||||
timeout: z.number().min(1).max(900).optional().default(3),
|
||||
memorySize: z.number().min(128).max(10240),
|
||||
environmentVariables: z.record(z.string()).default({}),
|
||||
tags: z.record(z.string()).default({}),
|
||||
@@ -108,8 +110,6 @@ async function createLambdaFunction(
|
||||
params: DeployRequest,
|
||||
zipBuffer: Buffer
|
||||
): Promise<any> {
|
||||
|
||||
|
||||
const createParams = {
|
||||
FunctionName: params.functionName,
|
||||
Runtime: params.runtime as Runtime,
|
||||
@@ -190,26 +190,26 @@ export async function POST(request: NextRequest) {
|
||||
return createErrorResponse('Invalid JSON in request body', 400, 'INVALID_JSON')
|
||||
}
|
||||
|
||||
logger.info(`[${requestId}] Request body received:`, {
|
||||
logger.info(`[${requestId}] Request body received:`, {
|
||||
body,
|
||||
codeType: typeof body.code,
|
||||
codeValue: body.code
|
||||
codeValue: body.code,
|
||||
})
|
||||
|
||||
|
||||
// Parse the code field if it's a JSON string
|
||||
if (typeof body.code === 'string') {
|
||||
try {
|
||||
body.code = JSON.parse(body.code)
|
||||
logger.info(`[${requestId}] Parsed code field:`, { parsedCode: body.code })
|
||||
} catch (parseError) {
|
||||
logger.error(`[${requestId}] Failed to parse code field as JSON`, {
|
||||
logger.error(`[${requestId}] Failed to parse code field as JSON`, {
|
||||
error: parseError instanceof Error ? parseError.message : String(parseError),
|
||||
codeString: body.code
|
||||
codeString: body.code,
|
||||
})
|
||||
return createErrorResponse('Invalid JSON in code field', 400, 'INVALID_CODE_JSON')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const validationResult = DeployRequestSchema.safeParse(body)
|
||||
if (!validationResult.success) {
|
||||
logger.warn(`[${requestId}] Invalid request body`, { errors: validationResult.error.errors })
|
||||
@@ -217,11 +217,11 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
const params = validationResult.data
|
||||
logger.info(`[${requestId}] Validation successful, params:`, {
|
||||
logger.info(`[${requestId}] Validation successful, params:`, {
|
||||
functionName: params.functionName,
|
||||
runtime: params.runtime,
|
||||
codeKeys: Object.keys(params.code),
|
||||
hasRole: !!params.role
|
||||
hasRole: !!params.role,
|
||||
})
|
||||
|
||||
// Create Lambda client
|
||||
|
||||
@@ -165,7 +165,8 @@ export const AWSLambdaBlock: BlockConfig<AWSLambdaResponse> = {
|
||||
type: 'code',
|
||||
layout: 'full',
|
||||
language: 'json',
|
||||
placeholder: '{\n "index.js": "exports.handler = async (event) => {\\n return {\\n statusCode: 200,\\n body: JSON.stringify({\\n message: \\"Hello from Lambda!\\"\\n })\\n };\\n };"\n}',
|
||||
placeholder:
|
||||
'{\n "index.js": "exports.handler = async (event) => {\\n return {\\n statusCode: 200,\\n body: JSON.stringify({\\n message: \\"Hello from Lambda!\\"\\n })\\n };\\n };"\n}',
|
||||
condition: {
|
||||
field: 'operationType',
|
||||
value: ['create/update'],
|
||||
|
||||
@@ -81,7 +81,8 @@ export const awsLambdaDeployTool: ToolConfig<AWSLambdaDeployInput, AWSLambdaDepl
|
||||
code: {
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'Function code files as JSON object with file paths as keys and code content as values',
|
||||
description:
|
||||
'Function code files as JSON object with file paths as keys and code content as values',
|
||||
},
|
||||
requirements: {
|
||||
type: 'string',
|
||||
|
||||
Reference in New Issue
Block a user