{"id":13527745,"url":"https://github.com/serverless/fdk","last_synced_at":"2025-08-21T08:31:17.403Z","repository":{"id":12790274,"uuid":"72749365","full_name":"serverless/fdk","owner":"serverless","description":"This library is deprecated. Please use https://github.com/serverless/event-gateway-sdk instead.","archived":false,"fork":false,"pushed_at":"2022-12-06T17:28:49.000Z","size":34808,"stargazers_count":69,"open_issues_count":5,"forks_count":4,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-11-02T12:35:05.680Z","etag":null,"topics":["serverless","serverless-framework","stdlib"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-03T13:43:27.000Z","updated_at":"2023-08-16T14:46:01.000Z","dependencies_parsed_at":"2023-01-14T07:45:15.769Z","dependency_job_id":null,"html_url":"https://github.com/serverless/fdk","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Ffdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Ffdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Ffdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Ffdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless","download_url":"https://codeload.github.com/serverless/fdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224891351,"owners_count":17387165,"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":["serverless","serverless-framework","stdlib"],"created_at":"2024-08-01T06:01:59.537Z","updated_at":"2024-11-16T08:04:41.842Z","avatar_url":"https://github.com/serverless.png","language":"JavaScript","readme":"**IMPORTANT**: This library is deprecated. Please use https://github.com/serverless/event-gateway-sdk instead.\n\n# Function Development Kit (aka FDK)\n\nNode.js library to improve developer experience developing Serverless applications.\n\nIt contains a client to configure and interact with the [Event Gateway](https://github.com/serverless/event-gateway).\n\n[![Build Status](https://travis-ci.org/serverless/fdk.svg?branch=master)](https://travis-ci.org/serverless/fdk)\n\n## Install (Node)\n\n```bash\nnpm install @serverless/fdk\n```\n\n## Install (Browser)\n\n```html\n\u003cscript type=\"text/javascript\" src=\"https://unpkg.com/@serverless/fdk@latest/dist/fdk.min.js\"\u003e\u003c/script\u003e\n```\n\nThe FDK then will be attached to window e.g. and you can access it via `window.fdk`\n\n## Create an Event Gateway Client\n\n```js\nconst fdk = require('@serverless/fdk');\nconst eventGateway = fdk.eventGateway({\n  url: 'http://localhost',\n})\n```\n\nOptional Properties for `eventGateway`\n\n```js\n{\n  // defaults to the provide URL + default config port 4001\n  configurationUrl: 'http://localhost:4001'\n  // optional property to provide their own http lib\n  fetchClient: fetch\n}\n```\n\n## Invoke a Function\n\n```js\neventGateway.invoke({\n  functionId: \"createUser\",\n  data: { name: \"Max\" },\n})\n```\n\nReturns a Promise with the response.\n\nThe value of data is converted using `JSON.stringify` by default since the default dataType is `application/json`. This is not happening and the value is passed as it is when the property `dataType` is provided.\n\n### Invoke a Function with a Custom Data Type\n\n```js\neventGateway.invoke({\n  functionId: \"createUser\",\n  data: \"Max\",\n  dataType: \"text/plain\",\n})\n```\n\n## Emit an Event\n\n```js\neventGateway.emit({\n  event: \"userCreated\",\n  data: { name: \"Max\" },\n})\n```\n\nReturns a Promise and when resolved the response only indicates if the Event Gateway received the event. Responses from any subscribed functions are not part of the response.\n\nThe value of data is converted using `JSON.stringify` by default since the default dataType is `application/json`. This is not happening and the value is passed as it is when the property `dataType` is provided.\n\n### Emit an Event with a Custom Data Type\n\n```js\neventGateway.emit({\n  event: \"userCreated\",\n  data: \"This is a string message.\",\n  dataType: \"text/plain\",\n})\n```\n\n## Configure an Event Gateway\n\nConfigure accepts an object of function and subscription definitions. The idea of exposing one configuration function is to provide developers with convenient utility to configure an Event Gateway in one call rather then dealing with a chain of Promise based calls. Nevertheless in addition we expose a wrapper function for each low-level API call to the Event Gateway described in this [section](#further-event-gateway-functions).\n\n```js\neventGateway.configure({\n  // list of all the functions that should be registered\n  functions: [\n    {\n      functionId: \"helloWorld\"\n      provider: {\n        type: \"awslambda\"\n        arn: \"xxx\",\n        region: \"us-west-2\",\n      }\n    },\n    {\n      functionId: \"sendWelcomeMail\"\n      provider: {\n        type: \"gcloudfunction\"\n        name: \"sendWelcomeEmail\",\n        region: \"us-west-2\",\n      }\n    }\n  ],\n  // list of all the subscriptions that should be created\n  subscriptions: [\n    {\n      event: \"http\",\n      method: \"GET\",\n      path: \"/users\",\n      functionId: \"helloWorld\"\n    },\n    {\n      event: \"user.created\",\n      functionId: \"sendEmail\"\n    }\n  ]\n})\n```\n\nReturns a promise which contains all the same list of functions and subscriptions in the same structure and order as provided in the configuration argument.\n\n```js\neventGateway.configure({ config })\n  .then((response) =\u003e {\n    console.log(response)\n    // {\n    //   functions: [\n    //     { functionId: 'xxx', … },\n    //     { functionId: 'xxx', … }\n    //   ],\n    //   subscriptions: [\n    //     { subscriptionId: 'xxx', … },\n    //     { subscriptionId: 'xxx', … }\n    //   ]\n    // }\n  })\n```\n\n## Reset the configuration\n\nReset removes all the existing subscriptions and functions.\n\n```js\neventGateway.resetConfiguration()\n```\n\n## Further Event Gateway Functions\n\n```js\n// Returns a function\neventGateway.registerFunction({\n  functionId: \"sendEmail\"\n  provider: {\n    type: \"awslambda\"\n    arn: \"xxx\",\n    region: \"us-west-2\",\n  }\n})\n\n// Returns undefined\neventGateway.deleteFunction({ functionId: \"sendEmail\" })\n\n// Returns an Array of functions\neventGateway.listFunctions()\n\n// Returns a subscription: { subscriptionId, event, functionId}\neventGateway.subscribe({\n  event: \"user.created\",\n  functionId: \"sendEmail\"\n})\n\n// Returns undefined\neventGateway.unsubscribe({\n  subscriptionId: \"user.created-sendEmail\"\n})\n\n// Returns an Array of subscriptions\neventGateway.listSubscriptions()\n```\n\n## Contribute\n\nIf you are interested to contribute we recommend to check out the [Contributing](https://github.com/serverless/fdk/blob/master/CONTRIBUTING.md) document as it explains how to get started and some of the design decisions for this library.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Ffdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless%2Ffdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Ffdk/lists"}