{"id":50907300,"url":"https://github.com/matejvasek/fn-testing-q","last_synced_at":"2026-06-16T06:30:52.964Z","repository":{"id":363907732,"uuid":"1265512009","full_name":"matejvasek/fn-testing-q","owner":"matejvasek","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-10T20:57:01.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-10T22:22:03.310Z","etag":null,"topics":["serverless-function"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/matejvasek.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-10T20:56:54.000Z","updated_at":"2026-06-10T20:57:43.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/matejvasek/fn-testing-q","commit_stats":null,"previous_names":["matejvasek/fn-testing-q"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/matejvasek/fn-testing-q","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matejvasek%2Ffn-testing-q","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matejvasek%2Ffn-testing-q/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matejvasek%2Ffn-testing-q/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matejvasek%2Ffn-testing-q/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matejvasek","download_url":"https://codeload.github.com/matejvasek/fn-testing-q/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matejvasek%2Ffn-testing-q/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34393304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["serverless-function"],"created_at":"2026-06-16T06:30:49.849Z","updated_at":"2026-06-16T06:30:52.959Z","avatar_url":"https://github.com/matejvasek.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js HTTP Function\n\nWelcome to your new Node.js function project! The boilerplate function code can be found in [`index.js`](./index.js). This function will respond to incoming HTTP GET and POST requests. This example function is written synchronously, returning a raw value. If your function performs any asynchronous execution, you can safely add the `async` keyword to the function, and return a `Promise`.\n\n## Local execution\n\nAfter executing `npm install`, you can run this function locally by executing `npm run local`.\n\nThe runtime will expose three endpoints.\n\n  * `/` The endpoint for your function.\n  * `/health/readiness` The endpoint for a readiness health check\n  * `/health/liveness` The endpoint for a liveness health check\n\nThe parameter provided to the function endpoint at invocation is a `Context` object containing HTTP request information.\n\n```js\nfunction handleRequest(context) {\n  const log = context.log;\n  log.info(context.httpVersion);\n  log.info(context.method); // the HTTP request method (only GET or POST supported)\n  log.info(context.query); // if query parameters are provided in a GET request\n  log.info(context.body); // contains the request body for a POST request\n  log.info(context.headers); // all HTTP headers sent with the event\n}\n```\n\nThe health checks can be accessed in your browser at [http://localhost:8080/health/readiness]() and [http://localhost:8080/health/liveness](). You can use `curl` to `POST` an event to the function endpoint:\n\n```console\ncurl -X POST -d '{\"hello\": \"world\"}' \\\n  -H'Content-type: application/json' \\\n  http://localhost:8080\n```\n\nThe readiness and liveness endpoints use [overload-protection](https://www.npmjs.com/package/overload-protection) and will respond with `HTTP 503 Service Unavailable` with a `Client-Retry` header if your function is determined to be overloaded, based on the memory usage and event loop delay.\n\n## The Function Interface\n\nThe `index.js` file may export a single function or a `Function`\nobject. The `Function` object allows developers to add lifecycle hooks for\ninitialization and shutdown, as well as providing a way to implement custom\nhealth checks.\n\nThe `Function` interface is defined as:\n\n```typescript\nexport interface Function {\n  // The initialization function, called before the server is started\n  // This function is optional and should be synchronous.\n  init?: () =\u003e any;\n\n  // The shutdown function, called after the server is stopped\n  // This function is optional and should be synchronous.\n  shutdown?: () =\u003e any;\n\n  // The liveness function, called to check if the server is alive\n  // This function is optional and should return 200/OK if the server is alive.\n  liveness?: HealthCheck;\n\n  // The readiness function, called to check if the server is ready to accept requests\n  // This function is optional and should return 200/OK if the server is ready.\n  readiness?: HealthCheck;\n\n  logLevel?: LogLevel;\n\n  // The function to handle HTTP requests\n  handle: CloudEventFunction | HTTPFunction;\n}\n```\n\n## Handle Signature\n\nThe HTTP function interface is defined as:\n\n```typescript\ninterface HTTPFunction {\n  (context: Context, body?: IncomingBody): HTTPFunctionReturn;\n}\n```\n\nWhere the `IncomingBody` is either a string, a Buffer, a JavaScript object, or undefined, depending on what was supplied in the HTTP POST message body. The `HTTTPFunctionReturn` type is defined as:\n\n```typescript\ntype HTTPFunctionReturn = Promise\u003cStructuredReturn\u003e | StructuredReturn | ResponseBody | void;\n```\n\nWhere the `StructuredReturn` is a JavaScript object with the following properties:\n\n```typescript\ninterface StructuredReturn {\n  statusCode?: number;\n  headers?: Record\u003cstring, string\u003e;\n  body?: ResponseBody;\n}\n```\n\nIf the function returns a `StructuredReturn` object, then the `statusCode` and `headers` properties are used to construct the HTTP response. If the `body` property is present, it is used as the response body. If the function returns `void` or `undefined`, then the response body is empty.\n\nThe `ResponseBody` is either a string, a JavaScript object, or a Buffer. JavaScript objects will be serialized as JSON. Buffers will be sent as binary data.\n\n### Health Checks\n\nThe `Function` interface also allows for the addition of a `liveness` and `readiness` function. These functions are used to implement health checks for the function. The `liveness` function is called to check if the function is alive. The `readiness` function is called to check if the function is ready to accept requests. If either of these functions returns a non-200 status code, then the function is considered unhealthy.\n\nA health check function is defined as:\n\n```typescript\n/**\n * The HealthCheck interface describes a health check function,\n * including the optional path to which it should be bound.\n */\nexport interface HealthCheck {\n  (request: Http2ServerRequest, reply: Http2ServerResponse): any;\n  path?: string;\n}\n```\n\nBy default, the health checks are bound to the `/health/liveness` and `/health/readiness` paths. You can override this by setting the `path` property on the `HealthCheck` object, or by setting the `LIVENESS_URL` and `READINESS_URL` environment variables.\n## Testing\n\nThis function project includes a [unit test](./test/unit.js) and an [integration test](./test/integration.js). All `.js` files in the test directory are run.\n\n```console\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatejvasek%2Ffn-testing-q","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatejvasek%2Ffn-testing-q","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatejvasek%2Ffn-testing-q/lists"}