{"id":18387641,"url":"https://github.com/geins-io/lp-integration-serverless","last_synced_at":"2025-04-14T05:51:30.553Z","repository":{"id":154189236,"uuid":"617354084","full_name":"geins-io/lp-integration-serverless","owner":"geins-io","description":"Starting point for creating a serverless integration to geins","archived":false,"fork":false,"pushed_at":"2023-05-15T13:44:02.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T19:42:03.294Z","etag":null,"topics":["azure-functions","ecommerce","serverless"],"latest_commit_sha":null,"homepage":"https://www.geins.io","language":"JavaScript","has_issues":false,"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/geins-io.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-03-22T08:06:26.000Z","updated_at":"2023-07-04T08:21:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"82830077-2389-4c41-9a69-9fa3af77544a","html_url":"https://github.com/geins-io/lp-integration-serverless","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geins-io%2Flp-integration-serverless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geins-io%2Flp-integration-serverless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geins-io%2Flp-integration-serverless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geins-io%2Flp-integration-serverless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geins-io","download_url":"https://codeload.github.com/geins-io/lp-integration-serverless/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830389,"owners_count":21168272,"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":["azure-functions","ecommerce","serverless"],"created_at":"2024-11-06T01:27:08.928Z","updated_at":"2025-04-14T05:51:30.532Z","avatar_url":"https://github.com/geins-io.png","language":"JavaScript","readme":"# Introduction\nThis integration launchpad comes with full features set optimized to build agains Geins Management API.\n\n\n## Pre-requisites\n- Node.js\n- Azure Account (Storage Account, Table Storage, Queue Storage) [Get a free account here](https://azure.microsoft.com/en-us/free/)\n- Geins Management API Account. [Get a free trial here](https://www.geins.io)\n\n\n## Features\n- [x] Authentication\n- [x] Geins API Client\n- [x] Logging in Azure Table Storage\n- [x] Queue Storage\n- [x] Queue Trigger\n- [x] HTTP Trigger\n- [x] Timer Trigger\n- [x] Log search via http request and response\n\n## Getting started \nRun the following command to install the dependencies:\n```bash\nnpm install\n```\n\nAdd the `local.settings.json` file to the root of the project. The `local.settings.json` file is used to store the credentials for the Azure Storage Account and Geins Management API. The `local.settings.json` file is not checked in to the repository.\n\n```json\n{\n  \"IsEncrypted\": false,\n  \"Values\": {\n    \"ENVIRONMENT\" : \"development\",\n    \"FUNCTIONS_WORKER_RUNTIME\": \"node\",\n    \"AZURE_ACCOUNT_NAME\": \"YOUR_ACCOUNT_NAME\",\n    \"AZURE_ACCOUNT_KEY\": \"YOUT_ACCOUNT_KEY\",\n    \"AZURE_TABLE_NAME\": \"log\",\n    \"AZURE_QUEUE_NAME\": \"queue-items\",\n    \"GEINS_MGMT_API_KEY\": \"YOUR_API_KEY\",\n    \"GEINS_MGMT_API_USERMAME\": \"YOUR_API_USERNAME\",\n    \"GEINS_MGMT_API_PASSWORD\": \"YOuR_API_PASSWORD\",\n    \"ENVIRONMENT\" : \"development\",\n    \"AzureWebJobsStorage\": \"AZURE_STORAGE_ACCOUNT_CONNECTION_STRING\"\n  },\n  \"Host\": {\n    \"CORS\": \"*\"\n  }\n}\n```\n\nRun the following command to start the function app:\n```bash\nfunc start\n```\n\n\n\n### Authentication\n@azure/core-auth is used for authentication. You can find more information here: https://www.npmjs.com/package/@azure/core-auth\n\n- For the table storage and queue storage, you can use the connection string or credentials. \n- For the Geins API, you use api-user credentialas and api-key. Read more at docs.geins.io.\n\nUpdate the `local.settings.json` file with your credentials:\n```json\n{\n  \"IsEncrypted\": false,\n  \"Values\": {\n    \"ENVIRONMENT\" : \"development\",\n    \"FUNCTIONS_WORKER_RUNTIME\": \"node\",\n    \"AZURE_ACCOUNT_NAME\": \"YOUR_ACCOUNT_NAME\",\n    \"AZURE_ACCOUNT_KEY\": \"YOUT_ACCOUNT_KEY\",\n    \"AZURE_TABLE_NAME\": \"log\",\n    \"AZURE_QUEUE_NAME\": \"queue-items\",\n    \"GEINS_MGMT_API_KEY\": \"YOUR_API_KEY\",\n    \"GEINS_MGMT_API_USERMAME\": \"YOUR_API_USERNAME\",\n    \"GEINS_MGMT_API_PASSWORD\": \"YOuR_API_PASSWORD\"\n  }\n}\n```\n\n\n### Logging\nThe logging is done via the `Logger` class that is exposed throug the `util` module as `logger`. The logger is configured to log to Azure Table Storage. The table name is configured in the `local.settings.json` file.\n\nTo log a message, use the `saveLog` method:\n```javascript\nutil.logger.saveLog(origin, action, payload);\n```\n| Parameter | Info | Example |\n|-|-|-|\n| origin | Origin of request | `PostmanRuntime/7.31.1` or IP |\n| action | Action | `syncUser` |\n| payload | Payload | `{ text: 'Hello World! '}` | \n\n### Queue Storage\nThe queue storage is configured to use the `AZURE_QUEUE_NAME` from the `local.settings.json` file. The queue storage is used to store the queue items that are used to trigger the queue trigger.\n\n### HTTP Trigger\nTrigger to put action and payload in the queue. The queue item is a JSON object with the following structure:\n```json\n{\n  \"action\": \"syncUser\",\n  \"payload\": {\n    \"id\": \"1234567890\",\n    \"name\": \"John Doe\"\n  }\n}\n```\n\n### Log search \nExposed throug an HTTP trigger. The log search is done via the `fetchLogs` class that is exposed throug the `util` module as `logger.fetchLogs(filter)`. Filter is an object with the following structure:\n```javascript\n{ \n    origin: 'PostmanRuntime/7.31.1', \n    action: 'sendEmail',\n}\n```\n\n### Timer Trigger\nUsed to put a queue item in the queue. Schedule for the timer trigger is configured in the `function.json` file. Schedule is a cron expression see the documentation here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=csharp#ncrontab-expressions.\n\nThe queue item is a JSON object with the following structure:\n```json\n{\n  \"action\": \"syncUser\",\n  \"payload\": {\n    \"id\": \"1234567890\",\n    \"name\": \"John Doe\"\n  }\n}\n```\n\n### Queue Trigger\nTrigger to process the queue items. The queue item is a JSON object with the following structure:\n```json\n{\n  \"action\": \"syncUser\",\n  \"payload\": {\n    \"id\": \"1234567890\",\n    \"name\": \"John Doe\"\n  }\n}\n```\n\n## Actions\nAn action is a function that is used to process the queue item. The action is a function that is exposed throug the `actions` module. The action is a function that is used in the `queueTrigger` function.\n\n| Variable | Info | Example |\n|-|-|-|\n| origin | Origin of request | `queue-trigger` |\n| action | Action | `sync` |\n| family | Family | `user` |\n| output | Output | `action.output.push(new util.Output(util.OutputType.API_PUSH, new util.MyParser()));` |\n| payload | Payload | `{ text: 'Hello World! '}` |\n\n## Output\nThe Output class is used to output the result of the queue item. An Output object has the following structure:\n```javascript\nnew util.Output(util.OutputType.API_PUSH, new util.MyParser());\n```\n| Variable | Info | Example |\n|-|-|-|\n| type | Type of output | `API_PUSH` |\n| parser | Parser | `new util.MyParser()` |\n\n## OutputType\nThe OutputType enum is used to define the type of output. The OutputType enum is exposed throug the `util` module as `OutputType`. The OutputType enum is used in the `Output` class.\n\n## Parsers\nParser is added to an Output object. The parser is used to parse the result of the queue item. Parser must implement the `parse` method. The `parse` method is used to parse the result of the queue item. The `parse` method is used in the `queueTrigger` function.\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeins-io%2Flp-integration-serverless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeins-io%2Flp-integration-serverless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeins-io%2Flp-integration-serverless/lists"}