{"_id":"@affordant/express","_rev":"2-7fd583f21bf19d358d2119d870dc5f2c","name":"@affordant/express","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@affordant/express","version":"0.2.0","keywords":["hateoas","hypermedia","affordance","express","node"],"author":{"name":"Florian Leroy"},"license":"MIT","_id":"@affordant/express@0.2.0","maintainers":[{"name":"hijoxx","email":"floroy32@gmail.com"}],"homepage":"https://leroy-florian.github.io/Affordant/","bugs":{"url":"https://github.com/Leroy-Florian/Affordant/issues"},"dist":{"shasum":"366a24a49f7dbc2945731a6e50d8cdf9eb87fb60","tarball":"https://registry.npmjs.org/@affordant/express/-/express-0.2.0.tgz","fileCount":6,"integrity":"sha512-dC3v7j9MGZLGE6ZIiaNGBEivngvhfl7/baJFuiisg1QX8UnGtou9HRVFS2nfnrtDhKjBIvVEAjUvXHPUKo4zlw==","signatures":[{"sig":"MEUCIQDFcU/5rS/WoESvEdCt8XcHAdKuTDMvgNFAL1e5c4Q7IgIgAkpXriTg/KHWNgRQFBzWbtHrB6ePxgUEj3U5phuYsZ0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@affordant%2fexpress@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":5697},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"f6e1abef80c7cbbf221fc6781d60c66a683cc7a9","scripts":{"test":"vitest run","build":"node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json","typecheck":"tsc -p tsconfig.json"},"_npmUser":{"name":"hijoxx","email":"floroy32@gmail.com"},"repository":{"url":"git+https://github.com/Leroy-Florian/Affordant.git","type":"git","directory":"packages/express"},"_npmVersion":"10.8.2","description":"Express adapter for Affordant: send the hypermedia envelope from your controllers and build absolute action URLs from the request.","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","dependencies":{"@affordant/server":"^0.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"express":">=4"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/express_0.2.0_1780691935670_0.6235182603171758","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@affordant/express","version":"0.3.0","description":"Express adapter for Affordant: send the hypermedia envelope from your controllers and build absolute action URLs from the request.","license":"MIT","author":{"name":"Florian Leroy"},"repository":{"type":"git","url":"git+https://github.com/Leroy-Florian/Affordant.git","directory":"packages/express"},"homepage":"https://leroy-florian.github.io/Affordant/","bugs":{"url":"https://github.com/Leroy-Florian/Affordant/issues"},"keywords":["hateoas","hypermedia","affordance","express","node"],"type":"module","sideEffects":false,"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"publishConfig":{"access":"public"},"dependencies":{"@affordant/server":"^0.2.0"},"peerDependencies":{"express":">=4"},"peerDependenciesMeta":{"express":{"optional":true}},"scripts":{"build":"node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json","typecheck":"tsc -p tsconfig.json","test":"vitest run"},"_id":"@affordant/express@0.3.0","gitHead":"792e727a12d26bf0d51ccd037a8f688c3389843b","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-3wtCTM99CBtL/bzhQvEr9pS1VaVSPw3zQSx7heE1UHtN/piZjPlDh25zXRpkfukA7VpEWu9esAuAOeJoi3Flig==","shasum":"fc147b99ecca921ff30a66c7817b7c842ac0c98e","tarball":"https://registry.npmjs.org/@affordant/express/-/express-0.3.0.tgz","fileCount":6,"unpackedSize":7025,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@affordant%2fexpress@0.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDxkszdRbMDqMM+yqfD2niaS38fR/ZFRaNhzV7Zo/RTSAiBGa9fATV+sov3n+/2imUxCziRBK63sfc+u+U/nTFW6TQ=="}]},"_npmUser":{"name":"hijoxx","email":"floroy32@gmail.com"},"directories":{},"maintainers":[{"name":"hijoxx","email":"floroy32@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/express_0.3.0_1781020772569_0.11900543376829398"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-05T20:38:55.537Z","modified":"2026-06-09T15:59:33.016Z","0.2.0":"2026-06-05T20:38:55.805Z","0.3.0":"2026-06-09T15:59:32.725Z"},"bugs":{"url":"https://github.com/Leroy-Florian/Affordant/issues"},"author":{"name":"Florian Leroy"},"license":"MIT","homepage":"https://leroy-florian.github.io/Affordant/","keywords":["hateoas","hypermedia","affordance","express","node"],"repository":{"type":"git","url":"git+https://github.com/Leroy-Florian/Affordant.git","directory":"packages/express"},"description":"Express adapter for Affordant: send the hypermedia envelope from your controllers and build absolute action URLs from the request.","maintainers":[{"name":"hijoxx","email":"floroy32@gmail.com"}],"readme":"# @affordant/express\n\n[Express](https://expressjs.com) adapter for **Affordant**. It sends the [`@affordant/server`](https://www.npmjs.com/package/@affordant/server) envelope straight from your controllers and builds absolute action URLs from the incoming request.\n\nIt accepts real Express `req` / `res` objects structurally, so it adds **no runtime dependency** on Express (declared as an optional peer).\n\n## Install\n\n```sh\nnpm install @affordant/server @affordant/express\n```\n\n## Usage\n\n```ts\nimport { resource } from '@affordant/server'\nimport { sendResource, urlFor } from '@affordant/express'\n\napp.get('/orders/:id', (req, res) => {\n  const order = loadOrder(req.params.id)\n\n  sendResource(\n    res,\n    resource(order)\n      .self(urlFor(req, `/orders/${order.id}`))\n      .action('cancel', urlFor(req, `/orders/${order.id}/cancel`), {\n        method: 'POST',\n        when: req.user?.id === order.ownerId && order.status !== 'shipped',\n      }),\n  )\n})\n```\n\n## API\n\n| Export | Description |\n|---|---|\n| `urlFor(req, path)` | Absolute URL for `path` from the request's protocol + Host. |\n| `sendResource(res, builder)` | Build the envelope, emit a `Link: …; rel=\"self\"` header, send JSON. Returns `res`. |\n\n## License\n\nMIT\n","readmeFilename":"README.md"}