{"_id":"pg-cloudflare","_rev":"8-9386cabba34b3468d4fa91c5abaceb2f","name":"pg-cloudflare","dist-tags":{"beta":"1.1.2-alpha.1","latest":"1.2.7"},"versions":{"1.1.0":{"name":"pg-cloudflare","version":"1.1.0","license":"MIT","_id":"pg-cloudflare@1.1.0","maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"homepage":"https://github.com/brianc/node-postgres#readme","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"dist":{"shasum":"833d70870d610d14bf9df7afb40e1cba310c17a0","tarball":"https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.0.tgz","fileCount":8,"integrity":"sha512-tGM8/s6frwuAIyRcJ6nWcIvd3+3NmUKIs6OjviIm1HPPFEt5MzQDOTBQyhPWg/m0kCl95M6gA1JaIXtS8KovOA==","signatures":[{"sig":"MEQCIG6isB86ON2T7VMRDxOpa/c92vv7N9D4aJ2otUD9YNwRAiBaSry5Okc8fELfVOG9ki9uAp6a/B3RLvEEZPmlvOJ6UQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18732},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"14b840e96e57fc0617b5c4758f6318f774148ee4","scripts":{"test":"echo e2e test in pg package","build":"tsc","prepublish":"yarn build","build:watch":"tsc --watch"},"_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"repository":{"url":"git://github.com/brianc/node-postgres.git","type":"git","directory":"packages/pg-cloudflare"},"_npmVersion":"lerna/3.22.1/node@v16.13.1+arm64 (darwin)","description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","directories":{},"_nodeVersion":"16.13.1","_hasShrinkwrap":false,"devDependencies":{"ts-node":"^8.5.4","typescript":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/pg-cloudflare_1.1.0_1684165024885_0.6568250245689073","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"pg-cloudflare","version":"1.1.1","license":"MIT","_id":"pg-cloudflare@1.1.1","maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"homepage":"https://github.com/brianc/node-postgres#readme","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"dist":{"shasum":"e6d5833015b170e23ae819e8c5d7eaedb472ca98","tarball":"https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz","fileCount":12,"integrity":"sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==","signatures":[{"sig":"MEYCIQDsKhAw11barVdstSmzoLcqeY9vzfHP2hn0QWKXRuVJyAIhAPIEmGbvNizmgm9C+8CLPLPOGWVy4+SPNU+NRC0Rc4Ah","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19341},"main":"dist/empty.js","types":"dist/index.d.ts","exports":{"default":"./dist/empty.js","workerd":"./dist/index.js"},"gitHead":"eaafac36dc8f4a13f1fecc9e3420d35559fd8e2b","scripts":{"test":"echo e2e test in pg package","build":"tsc","prepublish":"yarn build","build:watch":"tsc --watch"},"_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"repository":{"url":"git://github.com/brianc/node-postgres.git","type":"git","directory":"packages/pg-cloudflare"},"_npmVersion":"lerna/3.22.1/node@v16.13.1+arm64 (darwin)","description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","directories":{},"_nodeVersion":"16.13.1","_hasShrinkwrap":false,"devDependencies":{"ts-node":"^8.5.4","typescript":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/pg-cloudflare_1.1.1_1687797431025_0.7744328483353657","host":"s3://npm-registry-packages"}},"1.1.2-alpha.0":{"name":"pg-cloudflare","version":"1.1.2-alpha.0","license":"MIT","_id":"pg-cloudflare@1.1.2-alpha.0","maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"homepage":"https://github.com/brianc/node-postgres#readme","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"dist":{"shasum":"d224a71c1763010ddb2b13e9ddc938a3a3ed3d82","tarball":"https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.2-alpha.0.tgz","fileCount":12,"integrity":"sha512-RtKI8mzNxl1YvrN/64J3SDvhq4+JDsxytSpotYFubAXg6M57fCFCWuhyefRznKmt0d9fSXPNLBBB0RYSeVKGnQ==","signatures":[{"sig":"MEUCIQDYGtXEJgYtlU+A1qWeYVcrPDcuv12pkM2omrrSkoFw4AIgIqwY0X+eV/pNHeyxKgEdVjSWdeZfHvN7GIM/gPzxZ1M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21131},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","gitHead":"56762beebf750fe7798354301237a5bc62ef7740","scripts":{"test":"echo e2e test in pg package","build":"tsc","prepublish":"yarn build","build:watch":"tsc --watch"},"_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"repository":{"url":"git://github.com/brianc/node-postgres.git","type":"git","directory":"packages/pg-cloudflare"},"_npmVersion":"lerna/3.22.1/node@v20.10.0+arm64 (darwin)","description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ts-node":"^8.5.4","typescript":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/pg-cloudflare_1.1.2-alpha.0_1745264803978_0.3664711054546157","host":"s3://npm-registry-packages-npm-production"}},"1.1.2-alpha.1":{"name":"pg-cloudflare","version":"1.1.2-alpha.1","license":"MIT","_id":"pg-cloudflare@1.1.2-alpha.1","maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"homepage":"https://github.com/brianc/node-postgres#readme","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"dist":{"shasum":"081337f708e281f9b6da46a1ed9ab2bcb5bdff76","tarball":"https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.2-alpha.1.tgz","fileCount":13,"integrity":"sha512-z+mLDrYgCxITVy4yA7ftc3beu8OueiRDV4cmy5hNy7ooT8riw1QXL6A1+gckwxDb6OOAWRAssk9qWcfv8gR9nw==","signatures":[{"sig":"MEQCIEK0xIc8+eyxBSCnLqJfGMeS4yMS6oEbGC/xPG0TxBd/AiAEVdD8V9uyaHLq6fgP61NMNrZ+6edkr3jKI3dsEy3OXw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21594},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./esm/index.mjs","default":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"306fa83d84e7f99558146892c5f9bf8421ac98e0","scripts":{"test":"echo e2e test in pg package","build":"tsc","prepublish":"yarn build","build:watch":"tsc --watch"},"_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"repository":{"url":"git://github.com/brianc/node-postgres.git","type":"git","directory":"packages/pg-cloudflare"},"_npmVersion":"lerna/3.22.1/node@v20.10.0+arm64 (darwin)","description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ts-node":"^8.5.4","typescript":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/pg-cloudflare_1.1.2-alpha.1_1745270211391_0.01943974504896473","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"pg-cloudflare","version":"1.2.0","license":"MIT","_id":"pg-cloudflare@1.2.0","maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"homepage":"https://github.com/brianc/node-postgres#readme","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"dist":{"shasum":"5b3a7a5cc98e1dce4dfadd2d1b9402665b711536","tarball":"https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.0.tgz","fileCount":13,"integrity":"sha512-dhfTv9ZhBLHHjFjh1qeA/0xbaF9ax9fVp+jFCWEDR3Qtdj6oM+GybEewsvAjDkH1mu6dpiH2MSKSHmVDrZqrGA==","signatures":[{"sig":"MEYCIQDcJeuch/sH2XNR3n64DJ12aAQpntAADI03Fws9jh9/dAIhANE5HBlUU5fpILMabTmqowkH2+dxCPNzCJVDq1OSPJGY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21646},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./esm/index.mjs","default":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"9ec9e5f58d5329d75e94c5a29f70d78de02bfe26","scripts":{"test":"echo e2e test in pg package","build":"tsc","prepublish":"yarn build","build:watch":"tsc --watch"},"_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"repository":{"url":"git://github.com/brianc/node-postgres.git","type":"git","directory":"packages/pg-cloudflare"},"_npmVersion":"lerna/3.22.1/node@v20.10.0+arm64 (darwin)","description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"devDependencies":{"ts-node":"^8.5.4","typescript":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/pg-cloudflare_1.2.0_1745337351461_0.10886599885640513","host":"s3://npm-registry-packages-npm-production"}},"1.2.5":{"name":"pg-cloudflare","version":"1.2.5","license":"MIT","_id":"pg-cloudflare@1.2.5","maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"homepage":"https://github.com/brianc/node-postgres#readme","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"dist":{"shasum":"2e3649c38a7a9c74a7e5327c8098a2fd9af595bd","tarball":"https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.5.tgz","fileCount":13,"integrity":"sha512-OOX22Vt0vOSRrdoUPKJ8Wi2OpE/o/h9T8X1s4qSkCedbNah9ei2W2765be8iMVxQUsvgT7zIAT2eIa9fs5+vtg==","signatures":[{"sig":"MEQCIEDvQujP8pZh6DIT7WB0K9rHsHu3+PBcVb4qCBdk1OKlAiBRvqT/2/VwqjGcqLrmiuh+HBKkozD8oo81RADWXo/saw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21646},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./esm/index.mjs","default":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"56e286257724783681f8830b2faa7d407b6563e7","scripts":{"test":"echo e2e test in pg package","build":"tsc","prepublish":"yarn build","build:watch":"tsc --watch"},"_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"repository":{"url":"git://github.com/brianc/node-postgres.git","type":"git","directory":"packages/pg-cloudflare"},"_npmVersion":"lerna/3.22.1/node@v20.10.0+arm64 (darwin)","description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"devDependencies":{"ts-node":"^8.5.4","typescript":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/pg-cloudflare_1.2.5_1745434134875_0.7599786276873626","host":"s3://npm-registry-packages-npm-production"}},"1.2.6":{"name":"pg-cloudflare","version":"1.2.6","license":"MIT","_id":"pg-cloudflare@1.2.6","maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"homepage":"https://github.com/brianc/node-postgres#readme","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"dist":{"shasum":"3f3afa99495492002d757df645b1be2b5aca099f","tarball":"https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.6.tgz","fileCount":13,"integrity":"sha512-uxmJAnmIgmYgnSFzgOf2cqGQBzwnRYcrEgXuFjJNEkpedEIPBSEzxY7ph4uA9k1mI+l/GR0HjPNS6FKNZe8SBQ==","signatures":[{"sig":"MEQCIGRQGacevdkpQ8ZwCR7ZOma5di2mjONRtpdxvrufK/rqAiBEfXVDL6ajSf0ko9l5oyKlPW2pfkMK0y3szKGwWYIVxQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22937},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"default":"./dist/empty.js","cloudflare":{"import":"./esm/index.mjs","require":"./dist/index.js"}}},"gitHead":"cd877a57612a39335a97b593111710d26126279d","scripts":{"test":"echo e2e test in pg package","build":"tsc","prepublish":"yarn build","build:watch":"tsc --watch"},"_npmUser":{"name":"brianc","actor":{"name":"brianc","type":"user","email":"brian.m.carlson@gmail.com"},"email":"brian.m.carlson@gmail.com"},"repository":{"url":"git://github.com/brianc/node-postgres.git","type":"git","directory":"packages/pg-cloudflare"},"_npmVersion":"lerna/3.22.1/node@v20.10.0+arm64 (darwin)","description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"devDependencies":{"ts-node":"^8.5.4","typescript":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/pg-cloudflare_1.2.6_1750261612166_0.5402713598124378","host":"s3://npm-registry-packages-npm-production"}},"1.2.7":{"name":"pg-cloudflare","version":"1.2.7","description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","main":"dist/index.js","types":"dist/index.d.ts","license":"MIT","devDependencies":{"ts-node":"^8.5.4","typescript":"^4.0.3"},"exports":{".":{"workerd":{"import":"./esm/index.mjs","require":"./dist/index.js"},"default":"./dist/empty.js"}},"scripts":{"build":"tsc","build:watch":"tsc --watch","prepublish":"yarn build","test":"echo e2e test in pg package"},"repository":{"type":"git","url":"git://github.com/brianc/node-postgres.git","directory":"packages/pg-cloudflare"},"gitHead":"8f8e7315e8f7c1bb01e98fdb41c8c92585510782","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"homepage":"https://github.com/brianc/node-postgres#readme","_id":"pg-cloudflare@1.2.7","_nodeVersion":"20.10.0","_npmVersion":"lerna/3.22.1/node@v20.10.0+arm64 (darwin)","dist":{"integrity":"sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==","shasum":"a1f3d226bab2c45ae75ea54d65ec05ac6cfafbef","tarball":"https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz","fileCount":13,"unpackedSize":23093,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDNv1l3IimSTM2KCOTbpMrKtLIEs1KauWTmr8NyEUwm3QIgFKjQr4ojiYQ06VGPKUHd1acWS6D5sd7Arb9eHEOgwnY="}]},"_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com","actor":{"name":"brianc","email":"brian.m.carlson@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pg-cloudflare_1.2.7_1751035963008_0.20856816993768312"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-15T15:37:04.884Z","modified":"2025-06-27T14:52:43.648Z","1.1.0":"2023-05-15T15:37:05.149Z","1.1.1":"2023-06-26T16:37:11.213Z","1.1.2-alpha.0":"2025-04-21T19:46:44.169Z","1.1.2-alpha.1":"2025-04-21T21:16:51.595Z","1.2.0":"2025-04-22T15:55:51.642Z","1.2.5":"2025-04-23T18:48:55.044Z","1.2.6":"2025-06-18T15:46:52.381Z","1.2.7":"2025-06-27T14:52:43.175Z"},"bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"license":"MIT","homepage":"https://github.com/brianc/node-postgres#readme","repository":{"type":"git","url":"git://github.com/brianc/node-postgres.git","directory":"packages/pg-cloudflare"},"description":"A socket implementation that can run on Cloudflare Workers using native TCP connections.","maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"readme":"# pg-cloudflare\n\n`pg-cloudflare` makes it easier to take an existing package that relies on `tls` and `net`, and make it work in environments where only `connect()` is supported, such as Cloudflare Workers.\n\n`pg-cloudflare` wraps `connect()`, the [TCP Socket API](https://github.com/wintercg/proposal-sockets-api) proposed within WinterCG, and implemented in [Cloudflare Workers](https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/), and exposes an interface with methods similar to what the `net` and `tls` modules in Node.js expose. (ex: `net.connect(path[, options][, callback])`). This minimizes the number of changes needed in order to make an existing package work across JavaScript runtimes.\n\n## Installation\n\n```\nnpm i --save-dev pg-cloudflare\n```\n\nThe package uses conditional exports to support bundlers that don't know about\n`cloudflare:sockets`, so the consumer code by default imports an empty file. To\nenable the package, resolve to the `cloudflare` condition in your bundler's\nconfig. For example:\n\n- `webpack.config.js`\n ```js\n export default {\n ...,\n resolve: { conditionNames: [..., \"workerd\"] },\n plugins: [\n // ignore cloudflare:sockets imports\n new webpack.IgnorePlugin({\n resourceRegExp: /^cloudflare:sockets$/,\n }),\n ],\n }\n ```\n- `vite.config.js`\n\n > [!NOTE]\n > If you are using the [Cloudflare Vite plugin](https://www.npmjs.com/package/@cloudflare/vite-plugin) then the following configuration is not necessary.\n\n ```js\n export default defineConfig({\n ...,\n resolve: {\n conditions: [..., \"workerd\"],\n },\n build: {\n ...,\n // don't try to bundle cloudflare:sockets\n rollupOptions: {\n external: [..., 'cloudflare:sockets'],\n },\n },\n })\n ```\n\n- `rollup.config.js`\n ```js\n export default defineConfig({\n ...,\n plugins: [..., nodeResolve({ exportConditions: [..., 'workerd'] })],\n // don't try to bundle cloudflare:sockets\n external: [..., 'cloudflare:sockets'],\n })\n ```\n- `esbuild.config.js`\n ```js\n await esbuild.build({\n ...,\n conditions: [..., 'workerd'],\n })\n ```\n\nThe concrete examples can be found in `packages/pg-bundler-test`.\n\n## How to use conditionally, in non-Node.js environments\n\nAs implemented in `pg` [here](https://github.com/brianc/node-postgres/commit/07553428e9c0eacf761a5d4541a3300ff7859578#diff-34588ad868ebcb232660aba7ee6a99d1e02f4bc93f73497d2688c3f074e60533R5-R13), a typical use case might look as follows, where in a Node.js environment the `net` module is used, while in a non-Node.js environment, where `net` is unavailable, `pg-cloudflare` is used instead, providing an equivalent interface:\n\n```js\nmodule.exports.getStream = function getStream(ssl = false) {\n const net = require('net')\n if (typeof net.Socket === 'function') {\n return net.Socket()\n }\n const { CloudflareSocket } = require('pg-cloudflare')\n return new CloudflareSocket(ssl)\n}\n```\n\n## Node.js implementation of the Socket API proposal\n\nIf you're looking for a way to rely on `connect()` as the interface you use to interact with raw sockets, but need this interface to be available in a Node.js environment, [`@arrowood.dev/socket`](https://github.com/Ethan-Arrowood/socket) provides a Node.js implementation of the Socket API.\n\n### license\n\nThe MIT License (MIT)\n\nCopyright (c) 2023 Brian M. Carlson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","readmeFilename":"README.md"}