{"id":18265400,"url":"https://github.com/pure180/loopback-session","last_synced_at":"2026-04-28T18:33:23.751Z","repository":{"id":37882123,"uuid":"260134116","full_name":"pure180/loopback-session","owner":"pure180","description":"\"Express-Session\" implementation for loopback-next","archived":false,"fork":false,"pushed_at":"2024-10-19T16:27:55.000Z","size":443,"stargazers_count":0,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T19:55:04.424Z","etag":null,"topics":["express-session","loopback-next","nodejs","restful-api","session-management"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pure180.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-04-30T06:44:27.000Z","updated_at":"2024-07-08T12:51:09.000Z","dependencies_parsed_at":"2024-12-22T15:25:43.927Z","dependency_job_id":"f560aba5-2996-4fd7-b3bf-11b2f7a88074","html_url":"https://github.com/pure180/loopback-session","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/pure180%2Floopback-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pure180%2Floopback-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pure180%2Floopback-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pure180%2Floopback-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pure180","download_url":"https://codeload.github.com/pure180/loopback-session/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247958710,"owners_count":21024821,"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":["express-session","loopback-next","nodejs","restful-api","session-management"],"created_at":"2024-11-05T11:18:06.101Z","updated_at":"2026-04-28T18:33:18.731Z","avatar_url":"https://github.com/pure180.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @loopback/session\n\n## This package is *Work In Progress*\n\n**Bucket list**\n - optimize code\n - create unit tests\n - Create inline documentations\n - Improve the documentation\n - Check the requirements for extending the loopback base packages\n\n## Architecture Overview\n\nUpcoming next\n\n## Usage\n\nTo use this component, you need to have an existing LoopBack 4 application.\n\n- create app: run `lb4 app`\n\nNext enable the session system in your application:\n\n- register session component in application\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eCheck The Code\u003c/strong\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n```ts\nimport { SessionBindings, SessionComponent, SessionConfig } from '@loopback/session';\n\nexport class MyApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    super(options);\n\n    // - configure the session -\n    this.configure\u003cSessionConfig\u003e(SessionBindings.COMPONENT).to({\n      // Assign your existing data source\n      DataSource: MemoryDataSource,\n\n      // Assign the session configuration\n      session: {\n        secret: 'xyz_12345678_zyx',\n        resave: false,\n        saveUninitialized: false,\n        name: 'sid'\n      }\n    });\n\n    // - register the session Component\n    this.component(SessionComponent);\n\n    // Set up the custom sequence\n    this.sequence(MySequence);\n\n    // Set up default home page\n    this.static('/', path.join(__dirname, '../public'));\n\n    this.projectRoot = __dirname;\n    // Customize @loopback/boot Booter Conventions here\n    this.bootOptions = {};\n  }\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n- Setup your sequence and wrap the request and response with the session provider.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eCheck The Code\u003c/strong\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n```ts\n\nimport { inject } from '@loopback/context';\nimport {\n  FindRoute,\n  InvokeMethod,\n  ParseParams,\n  Reject,\n  RequestContext,\n  RestBindings,\n  Send,\n  SequenceHandler,\n} from '@loopback/rest';\n\nimport { SessionFn, SessionBindings, SessionRequest } from '@loopback/session';\n\nconst SequenceActions = RestBindings.SequenceActions;\n\nexport class MySequence implements SequenceHandler {\n  constructor(\n    @inject(SequenceActions.FIND_ROUTE)\n      protected findRoute: FindRoute,\n    @inject(SequenceActions.PARSE_PARAMS)\n      protected parseParams: ParseParams,\n    @inject(SequenceActions.INVOKE_METHOD)\n      protected invoke: InvokeMethod,\n    @inject(SequenceActions.SEND)\n      public send: Send,\n    @inject(SequenceActions.REJECT) \n      public reject: Reject,\n\n    // Inject the session provider\n    @inject(SessionBindings.PROVIDER)\n      protected session: SessionFn\u003cSessionRequest\u003e,\n\n  ) {}\n\n  async handle(context: RequestContext) {\n    try {\n\n      // Wrap the incoming and outgoing messages with the session provider.\n      const {\n        request, \n        response\n      } = await this.session(context.request as SessionRequest, context.response as Response);\n\n      const route = this.findRoute(request);\n      const args = await this.parseParams(request, route);\n      const result = await this.invoke(route, args);\n      this.send(response, result);\n    } catch (err) {\n      this.reject(context, err);\n    }\n  }\n}\n\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n## Contributions\n\n- [Guidelines](https://github.com/strongloop/loopback-next/blob/master/docs/CONTRIBUTING.md)\n- [Join the team](https://github.com/strongloop/loopback-next/issues/110)\n\n## Tests\n\nRun `npm test` from the root folder.\n\n## Contributors\n\nSee\n[all contributors](https://github.com/strongloop/loopback-next/graphs/contributors).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpure180%2Floopback-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpure180%2Floopback-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpure180%2Floopback-session/lists"}