{"id":18960247,"url":"https://github.com/jaredhanson/junction","last_synced_at":"2025-04-15T11:12:51.548Z","repository":{"id":57286933,"uuid":"1448089","full_name":"jaredhanson/junction","owner":"jaredhanson","description":"Essential XMPP middleware for Node.js.","archived":false,"fork":false,"pushed_at":"2018-10-15T19:39:34.000Z","size":195,"stargazers_count":106,"open_issues_count":10,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T19:21:20.397Z","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/jaredhanson.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}},"created_at":"2011-03-07T00:00:57.000Z","updated_at":"2024-08-01T22:29:12.000Z","dependencies_parsed_at":"2022-09-20T01:42:25.031Z","dependency_job_id":null,"html_url":"https://github.com/jaredhanson/junction","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fjunction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fjunction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fjunction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fjunction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredhanson","download_url":"https://codeload.github.com/jaredhanson/junction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248920024,"owners_count":21183476,"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-08T14:04:57.025Z","updated_at":"2025-04-15T11:12:51.531Z","avatar_url":"https://github.com/jaredhanson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Junction\n\nJunction is an extensible [XMPP](http://xmpp.org/) middleware layer for [Node](http://nodejs.org).\nHighly scalable applications can be constructed by assembling sets of \"plugins\"\nknown as _middleware_ and _filters_.  Middleware process incoming stanzas, while\nfilters process outgoing stanzas.\n\nThis architecture has been proven effective by [Connect](http://www.senchalabs.org/connect/),\nwhich provides HTTP middleware.  Junction adopts this approach, repurposing it\nfor use in XMPP, allowing XMPP applications to be built quickly and easily,\nwhile harnessing the powerful patterns familiar to Node.js developers.\n\n## Installation\n\n    $ npm install junction\n\n## Usage\n\n#### Create an Application\n\nTo create a new application, simply invoke `junction()`.  Use the built in\nmessage and presence parsing middleware to parse common stanzas.\n\n    var app = junction()\n      .use(junction.messageParser())\n      .use(junction.presenceParser());\n\n#### Handle Stanzas\n\nUse additional middleware to define your application's behavior.  In this\nexample, the built in `message` middleware is used to handle chat messages.\nAnytime a message is received, we send a greeting and echo the message body.\n\n    app.use(junction.message(function(handler) {\n      handler.on('chat', function(stanza) {\n        var msg = new Message(stanza.from);\n        msg.c('body', {}).t('Hello ' + stanza.from + '!\\n\\n' +\n                            'You said: ' + stanza.body);\n        stanza.connection.send(msg);\n      });\n    }));\n    \nJunction provides [bundled middleware](https://github.com/jaredhanson/junction/tree/master/lib/junction/middleware)\nto handle core XMPP functionality.  Additional middleware and higher-level\nframeworks are available as separate modules.\n\n#### Trailing Middleware\n\nConclude the app by using the typical trailing middleware:\n\n    app.use(junction.serviceUnavailable())\n       .use(junction.errorHandler());\n\n`serviceUnavailable` middleware responds with a `service-unavailable` stanza\nerror when other XMPP entities send the application a request that it doesn't\nsupport.  This is recommended for well-behaved XMPP applications.\n\n`errorHandler` middleware will respond with stanza errors when the application\nencounters an error condition.\n\nThese middleware should be used _last_ in the stack, ensuring that other\nmiddleware take priority.\n\n#### Connect to XMPP Network\n\nWith the app configured, connect to the XMPP network.\n\n    app.connect({ jid: 'user@jabber.org', password: 's3cr3t' }).on('online', function() {\n      console.log('connected as: ' + this.jid);\n      this.send(new Presence());\n    });\n\nJunction uses [node-xmpp](https://github.com/astro/node-xmpp) for the underlying\nconnection, allowing apps to connect as clients, components, or any other\nsupported connection type.\n\n## Frameworks\n\nAt its core, XMPP is a protocol that allows structured data to be exchanged in\nreal-time between entities on the network.  While typically used for instant\nmessaging and presence, numerous XMPP extension protocols (known as XEPs) are\navailable which make XMPP broadly applicable to non-IM applications.\n\nThese XEPs build on XMPP's core, while defining their own higher-level\nsemantics.  Junction-based frameworks implement support for these extensions,\nbuilding on essential middleware and enhancing it with tooling designed to\nsupport development of applications making use of the XEP.\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\u003cth\u003eFramework\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-disco\"\u003eDisco\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eService Discovery (\u003ca href=\"http://xmpp.org/extensions/xep-0030.html\"\u003eXEP-0030\u003c/a\u003e) framework.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-pubsub\"\u003ePubSub\u003c/a\u003e\u003c/td\u003e\u003ctd\u003ePublish-Subscribe (\u003ca href=\"http://xmpp.org/extensions/xep-0060.html\"\u003eXEP-0060\u003c/a\u003e) framework.\u003c/td\u003e\u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Middleware\n\nAdditional middleware is available to parse non-core extension elements commonly\nfound in stanzas.  Some middleware implement complete support for simple XEPs\nthat don't justify the need for a full-fledged framework.\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\u003cth\u003eMiddleware\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-attention\"\u003ejunction-attention\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eAttention (\u003ca href=\"http://xmpp.org/extensions/xep-0224.html\"\u003eXEP-0224\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-delay\"\u003ejunction-delay\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eDelayed Delivery (\u003ca href=\"http://xmpp.org/extensions/xep-0203.html\"\u003eXEP-0203\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-lastactivity\"\u003ejunction-lastactivity\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eLast Activity (\u003ca href=\"http://xmpp.org/extensions/xep-0012.html\"\u003eXEP-0012\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-legacy-delay\"\u003ejunction-legacy-delay\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eLegacy Delayed Delivery (\u003ca href=\"http://xmpp.org/extensions/xep-0091.html\"\u003eXEP-0091\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-legacy-time\"\u003ejunction-legacy-time\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eLegacy Entity Time (\u003ca href=\"http://xmpp.org/extensions/xep-0090.html\"\u003eXEP-0090\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-nickname\"\u003ejunction-nickname\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eUser Nickname (\u003ca href=\"http://xmpp.org/extensions/xep-0172.html\"\u003eXEP-0172\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-ping\"\u003ejunction-ping\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eXMPP Ping (\u003ca href=\"http://xmpp.org/extensions/xep-0199.html\"\u003eXEP-0199\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-softwareversion\"\u003ejunction-softwareversion\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eSoftware Version (\u003ca href=\"http://xmpp.org/extensions/xep-0092.html\"\u003eXEP-0092\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/jaredhanson/junction-time\"\u003ejunction-time\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eEntity Time (\u003ca href=\"http://xmpp.org/extensions/xep-0202.html\"\u003eXEP-0202\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/Daniel15/junction-caps\"\u003ejunction-caps\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eEntity Capabilities (\u003ca href=\"http://xmpp.org/extensions/xep-0115.html\"\u003eXEP-0115\u003c/a\u003e) middleware.\u003c/td\u003e\u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Tests\n\n    $ npm install --dev\n    $ make test\n\n[![Build Status](https://secure.travis-ci.org/jaredhanson/junction.png)](http://travis-ci.org/jaredhanson/junction)\n\n## Credits\n\n  - [Jared Hanson](http://github.com/jaredhanson)\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2011-2017 Jared Hanson \u003c[http://jaredhanson.net/](http://jaredhanson.net/)\u003e\n\n\u003ca target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/vK9dyjRnnWsMzzJTQ57fRJpH/jaredhanson/junction'\u003e  \u003cimg alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/vK9dyjRnnWsMzzJTQ57fRJpH/jaredhanson/junction.svg' /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fjunction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredhanson%2Fjunction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fjunction/lists"}