{"id":13581523,"url":"https://github.com/logux/server","last_synced_at":"2025-04-14T02:57:53.665Z","repository":{"id":41251430,"uuid":"72019233","full_name":"logux/server","owner":"logux","description":"Build your own Logux server or make a proxy between a WebSocket and an HTTP backend in any language","archived":false,"fork":false,"pushed_at":"2025-01-22T06:52:04.000Z","size":4223,"stargazers_count":466,"open_issues_count":0,"forks_count":107,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-07T00:04:20.215Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://logux.org/","language":"TypeScript","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/logux.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":"2016-10-26T15:50:53.000Z","updated_at":"2025-03-25T02:04:49.000Z","dependencies_parsed_at":"2023-12-06T07:56:33.124Z","dependency_job_id":"4112617a-c0bd-40c7-92da-e79378192e22","html_url":"https://github.com/logux/server","commit_stats":{"total_commits":1111,"total_committers":36,"mean_commits":30.86111111111111,"dds":0.07290729072907287,"last_synced_commit":"0a78e42f3f999697581606c072b824396111a656"},"previous_names":["logux/logux-server"],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logux%2Fserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logux%2Fserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logux%2Fserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logux%2Fserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/logux","download_url":"https://codeload.github.com/logux/server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248456370,"owners_count":21106603,"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-08-01T15:02:04.295Z","updated_at":"2025-04-14T02:57:53.638Z","avatar_url":"https://github.com/logux.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Logux Server [![Cult Of Martians][cult-img]][cult]\n\n\u003cimg align=\"right\" width=\"95\" height=\"148\" title=\"Logux logotype\"\n     src=\"https://logux.org/branding/logotype.svg\"\u003e\n\nLogux is a new way to connect client and server. Instead of sending\nHTTP requests (e.g., AJAX and GraphQL) it synchronizes log of operations\nbetween client, server, and other clients.\n\n* **[Guide, recipes, and API](https://logux.org/)**\n* **[Issues](https://github.com/logux/logux/issues)**\n  and **[roadmap](https://github.com/orgs/logux/projects/1)**\n* **[Projects](https://logux.org/guide/architecture/parts/)**\n  inside Logux ecosystem\n\nThis repository contains Logux server with:\n\n* Framework to write own server.\n* Proxy between WebSocket and HTTP server on any other language.\n\n\u003ca href=\"https://evilmartians.com/?utm_source=logux-server\"\u003e\n  \u003cimg src=\"https://evilmartians.com/badges/sponsored-by-evil-martians.svg\"\n       alt=\"Sponsored by Evil Martians\" width=\"236\" height=\"54\"\u003e\n\u003c/a\u003e\n\n[cult-img]: http://cultofmartians.com/assets/badges/badge.svg\n[cult]: http://cultofmartians.com/done.html\n\n\n### Logux Server as Proxy\n\n```js\nimport { fileURLToPath } from 'url'\n\nconst server = new Server(\n  Server.loadOptions(process, {\n    controlSecret: 'secret',\n    subprotocol: '1.0.0',\n    supports: '0.6.2',\n    backend: 'http://localhost:3000/logux',\n    fileUrl: import.meta.url\n  })\n)\n\nserver.listen()\n```\n\n\n### Logux Server as Framework\n\n```js\nimport { fileURLToPath } from 'url'\nimport { isFirstOlder } from '@logux/core'\nimport { dirname } from 'path'\nimport { Server } from '@logux/server'\n\nconst server = new Server(\n  Server.loadOptions(process, {\n    subprotocol: '1.0.0',\n    supports: '1.x',\n    fileUrl: import.meta.url\n  })\n)\n\nserver.auth(async ({ userId, token }) =\u003e {\n  const user = await findUserByToken(token)\n  return !!user \u0026\u0026 userId === user.id\n})\n\nserver.channel('user/:id', {\n  access (ctx, action, meta) {\n    return ctx.params.id === ctx.userId\n  },\n  async load (ctx, action, meta) {\n    const user = await db.loadUser(ctx.params.id)\n    return { type: 'USER_NAME', name: user.name }\n  }\n})\n\nserver.type('CHANGE_NAME', {\n  access (ctx, action, meta) {\n    return action.user === ctx.userId\n  },\n  resend (ctx, action, meta) {\n    return { channel: `user/${ ctx.userId }` }\n  },\n  async process (ctx, action, meta) {\n    if (isFirstOlder(lastNameChange(action.user), meta)) {\n      await db.changeUserName({ id: action.user, name: action.name })\n    }\n  }\n})\n\nserver.listen()\n```\n\n[documentation]: https://logux.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogux%2Fserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flogux%2Fserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogux%2Fserver/lists"}