{"id":22586217,"url":"https://github.com/if1live/serverless-standalone","last_synced_at":"2025-03-28T17:26:39.635Z","repository":{"id":188003741,"uuid":"677946243","full_name":"if1live/serverless-standalone","owner":"if1live","description":"Emulate AWS λ and aws-sdk locally when developing your Serverless node.js project","archived":false,"fork":false,"pushed_at":"2023-12-31T18:05:48.000Z","size":233,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-02T18:14:40.157Z","etag":null,"topics":["aws-lambda","serverless"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/if1live.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-13T07:03:54.000Z","updated_at":"2024-06-20T08:40:31.000Z","dependencies_parsed_at":"2023-12-29T19:21:57.138Z","dependency_job_id":"9ab67607-ab48-4a9a-b8e0-f3f3d1a0e50e","html_url":"https://github.com/if1live/serverless-standalone","commit_stats":null,"previous_names":["if1live/serverless-standalone"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/if1live%2Fserverless-standalone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/if1live%2Fserverless-standalone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/if1live%2Fserverless-standalone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/if1live%2Fserverless-standalone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/if1live","download_url":"https://codeload.github.com/if1live/serverless-standalone/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246068299,"owners_count":20718505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","serverless"],"created_at":"2024-12-08T07:22:37.849Z","updated_at":"2025-03-28T17:26:39.607Z","avatar_url":"https://github.com/if1live.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serverless-standalone\n\nEmulate AWS λ and aws-sdk locally when developing your Serverless node.js project\n\n## features\n\n- AWS WebSocket API + @aws-sdk/client-apigatewaymanagementapi\n- [Schedule](https://www.serverless.com/framework/docs/providers/aws/events/schedule)\n\n## demo\n\n- server: `pnpm dev`, see `examples/dev.ts`\n- client: `wscat -c \"ws://127.0.0.1:9001/path?foo=1\u0026foo=2\"`\n- aws-sdk example: `node ./examples/index.mjs {connectionId}`\n\n## usage\n\ndefine serverless function. similar with serverless.yml.\n\n```ts\nconst websocket_connect: APIGatewayProxyHandler = async (event, context) =\u003e {\n  ...\n}\nconst websocket_disconnect: APIGatewayProxyHandler = async (event, context) =\u003e {\n  ...\n}\n\nconst definitions: FunctionDefinition[] = [\n  {\n    handler: websocket_connect,\n    events: [{ websocket: { route: \"$connect\" } }],\n  },\n  {\n    handler: websocket_disconnect,\n    events: [{ websocket: { route: \"$disconnect\" } }],\n  },\n];\n```\n\nstart serverless-standalone at localhost.\n\n```ts\nawait StandAlone.start(definitions, {\n  http: 9000,\n  websocket: 9001,\n  api: 9002,\n});\n```\n\nconnect websocket. aws lambda handler are invoked.\n`wscat -c \"ws://127.0.0.1:9001/path?username=me\u0026password=pw\"`\n\nuse aws-sdk locally.\n\n```ts\nconst client = new ApiGatewayManagementApiClient({\n  region: \"ap-northeast-1\",\n  endpoint: \"http://127.0.0.1:9001/\",\n  credentials: {\n    accessKeyId: \"localAccessKeyId\",\n    secretAccessKey: \"localAecretAccessKey\",\n  },\n});\n\nconst output = await client.send(\n  new PostToConnectionCommand({\n    ConnectionId: connectionId,\n    Data: new TextEncoder().encode(\"hello\"),\n  }),\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fif1live%2Fserverless-standalone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fif1live%2Fserverless-standalone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fif1live%2Fserverless-standalone/lists"}