{"id":19425558,"url":"https://github.com/botmasterai/botmaster-session-ware","last_synced_at":"2025-06-12T04:11:25.443Z","repository":{"id":71333364,"uuid":"79681108","full_name":"botmasterai/botmaster-session-ware","owner":"botmasterai","description":"configurable botmaster session ware ","archived":false,"fork":false,"pushed_at":"2017-10-26T12:56:36.000Z","size":57,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-14T09:08:43.343Z","etag":null,"topics":[],"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/botmasterai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-01-22T00:02:29.000Z","updated_at":"2017-07-15T22:12:06.000Z","dependencies_parsed_at":"2023-12-13T22:01:51.228Z","dependency_job_id":null,"html_url":"https://github.com/botmasterai/botmaster-session-ware","commit_stats":{"total_commits":34,"total_committers":5,"mean_commits":6.8,"dds":0.3529411764705882,"last_synced_commit":"cfe3a33007c0ba70bd915a77b0d0dddb7f09bef8"},"previous_names":["botmasterai/botmaster-context-session-ware"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botmasterai%2Fbotmaster-session-ware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botmasterai%2Fbotmaster-session-ware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botmasterai%2Fbotmaster-session-ware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botmasterai%2Fbotmaster-session-ware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/botmasterai","download_url":"https://codeload.github.com/botmasterai/botmaster-session-ware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240593185,"owners_count":19825939,"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":[],"created_at":"2024-11-10T14:04:06.198Z","updated_at":"2025-02-25T05:14:40.414Z","avatar_url":"https://github.com/botmasterai.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/botmasterai/botmaster-session-ware.svg?branch=master)](https://travis-ci.org/botmasterai/botmaster-session-ware)\n\n# Botmaster Session Ware\n\nA configurable botmaster ware to provide session data to downstream middleware. Works with Botmaster ^3.0.7.\n\n# Quick Start\n\n```bash\nnpm install botmaster-session-ware -S\n```\n\n```js\nconst Botmaster = require('botmaster');\nconst SessionWare = require('botmaster-session-ware');\n\nbotmaster.use({\n  type: 'incoming',\n  name: 'some controller',\n  controller: (bot, update) =\u003e {\n    // this will be {} on the first call from a certain user\n    // and will contain the last message upon all the next iterations\n    console.log(update.session);\n\n    update.session.lastMessage = update.message;\n  }\n})\n.\n.\n.\n// place after declaring all your other middleware\nconst sessionWare = SessionWare();\nbotmaster.useWrapped(sessionWare.incoming, sessionWare.outgoing);\n```\n\n# Using a different adapter\n\nAdapters should be provided in their own package. Their api must follow the MemoryStore example.\n\n## API\n\n### SessionWare\n\nCreate an object providing incoming and outgoing middleware that manages a \nsession object for you. By using this middleware, your other middleware will\nhave access to a persisted `update.session` object.\n\n**Parameters**\n\n-   `options` **\\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** options object for generated sessionWare\n    -   `options.adapter` **\\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an object implementing the adapter api. defaults to in MemoryStore.\n    -   `options.sessionPath` **\\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** dot denoted path to where to store the context in the update. defaults to 'session'\n\nReturns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object that contains two functions 'incoming' and 'outgoing'.\nThey should be used with the useWrapped method of botmaster\n\n### MemoryStore\n\nThe most basic adapter ever for SessionWare. This is the default store that is\nused when instantiating a SessionWare object without any params.\nIt provides the standard required API for stores. I.e. a getter and a setter method.\nCalled `get` and `set` that both return promises where get resolves with the session\nvalue and set sets the session value\n\n#### get\n\nGet or create a session with the id.\n\n**Parameters**\n\n-   `id` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a unique id for the session\n\nReturns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** evaluates to an object that is the  session\n\n#### set\n\nUpdate a session in the storage.\n\n**Parameters**\n\n-   `id` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a unique id for the session\n-   `value` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the new value for the session\n\nReturns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** resolves when the session has been saved\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotmasterai%2Fbotmaster-session-ware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbotmasterai%2Fbotmaster-session-ware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotmasterai%2Fbotmaster-session-ware/lists"}