{"_id":"pglite-server","_rev":"6-53a972e7313f2ad039c2205253cc8e00","name":"pglite-server","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.0":{"name":"pglite-server","version":"0.1.0","author":{"name":"Kamil Ogórek","email":"kamil.ogorek@gmail.com"},"license":"MIT","_id":"pglite-server@0.1.0","maintainers":[{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"}],"dist":{"shasum":"4db20da29eb6f21aed8fe7bce09328de5453f8ab","tarball":"https://registry.npmjs.org/pglite-server/-/pglite-server-0.1.0.tgz","fileCount":4,"integrity":"sha512-lAaPIpE1zf9b87WRI7RLu0sQTTb0Lr0yPcoS7pIJb7AeQeAefYqwmxt8Hhal7uJ97mRz+y7A+yHChnrGDkQOQQ==","signatures":[{"sig":"MEUCIQCEU8nspCRkFRcS1rFSsEvKdqJMag9Je0pQ02olyFeg/gIgWsDT7DeIFd4HZ8w0KygV2+0/vPVhDaTkQjLd1CeRdQY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10904},"type":"module","engines":{"node":">=20"},"exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"gitHead":"2d42b8c187baab57e0af897da69b59c98ae88ae1","scripts":{"test":"bun run test/main.ts","build":"tsup src/index.ts --format esm --dts"},"_npmUser":{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"},"_npmVersion":"10.5.0","description":"Wire Protocol Server for PGlite","directories":{},"_nodeVersion":"21.7.1","_hasShrinkwrap":false,"devDependencies":{"pg":"^8.11.5","tsup":"^8.0.2","@types/pg":"^8.11.4","typescript":"^5.4.3","@types/node":"^20.12.2","@electric-sql/pglite":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/pglite-server_0.1.0_1712390245459_0.5566624171110797","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"pglite-server","version":"0.1.1","author":{"name":"Kamil Ogórek","email":"kamil.ogorek@gmail.com"},"license":"MIT","_id":"pglite-server@0.1.1","maintainers":[{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"}],"homepage":"https://github.com/kamilogorek/pglite-server#readme","bugs":{"url":"https://github.com/kamilogorek/pglite-server/issues"},"dist":{"shasum":"48b73e2156bfcf6b030b1ee3ce1fc17e3f96ad3d","tarball":"https://registry.npmjs.org/pglite-server/-/pglite-server-0.1.1.tgz","fileCount":4,"integrity":"sha512-edq0GCk8qLOz9TRVu5z5UOVtcFR59bK1JYucqJ9GFdwN98AJkpsPTdSAw68N+UkH5R0h08rqjWj7QHHlOtdFhg==","signatures":[{"sig":"MEUCIHdF7leBtpyEp4X/v7tsX9Cr98FffULmNECeMoVX+mlUAiEA+0GJNcAZ+TNhyxPbkrpXSR2+m8pGQedFUaaZvsmqY04=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10968},"type":"module","engines":{"node":">=20"},"exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"gitHead":"c6ed5343c500e5db775457183367448ad0f3b6b0","scripts":{"test":"bun run test/main.ts","build":"tsup src/index.ts --format esm --dts"},"_npmUser":{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"},"repository":{"url":"git+https://github.com/kamilogorek/pglite-server.git","type":"git"},"_npmVersion":"10.5.0","description":"Wire Protocol Server for PGlite","directories":{},"_nodeVersion":"21.7.1","_hasShrinkwrap":false,"devDependencies":{"pg":"^8.11.5","tsup":"^8.0.2","@types/pg":"^8.11.4","typescript":"^5.4.4","@types/node":"^20.12.4","@electric-sql/pglite":"^0.1.2"},"_npmOperationalInternal":{"tmp":"tmp/pglite-server_0.1.1_1712391066379_0.5307559921503522","host":"s3://npm-registry-packages"}},"0.1.2":{"name":"pglite-server","version":"0.1.2","author":{"name":"Kamil Ogórek","email":"kamil.ogorek@gmail.com"},"license":"MIT","_id":"pglite-server@0.1.2","maintainers":[{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"}],"homepage":"https://github.com/kamilogorek/pglite-server#readme","bugs":{"url":"https://github.com/kamilogorek/pglite-server/issues"},"dist":{"shasum":"b3206f4a9fa5555c889b5501a0bfdb40e93e3a9d","tarball":"https://registry.npmjs.org/pglite-server/-/pglite-server-0.1.2.tgz","fileCount":4,"integrity":"sha512-SxS9uznM6UZRVTH97e8dbOap/VcaJm2JJMyCTJxDmlnvP1ODZyPn2AtvTab9sKqudmyXvoZy/TLE61GTg9K7Ag==","signatures":[{"sig":"MEUCIQD7dwuop3OxVPmqepgxdrRI3fRxOMXCc114LBaHaM6ATQIgAKqHLcK7jqU1xfpVK33TnVHG8c6OQcrTxkCQouFMN+4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11806},"type":"module","engines":{"node":">=20"},"exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"gitHead":"1f8b089067b9ee27056de1137995f933168e14bc","scripts":{"test":"bun run test/main.ts && bun run test/invalid-input.ts","build":"tsup src/index.ts --format esm --dts"},"_npmUser":{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"},"repository":{"url":"git+https://github.com/kamilogorek/pglite-server.git","type":"git"},"_npmVersion":"10.5.0","description":"Wire Protocol Server for PGlite","directories":{},"_nodeVersion":"21.7.1","_hasShrinkwrap":false,"devDependencies":{"pg":"^8.11.5","tsup":"^8.0.2","@types/pg":"^8.11.4","typescript":"^5.4.4","@types/node":"^20.12.4","@electric-sql/pglite":"^0.1.2"},"_npmOperationalInternal":{"tmp":"tmp/pglite-server_0.1.2_1715065090344_0.18214418693835976","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"pglite-server","version":"0.1.3","author":{"name":"Kamil Ogórek","email":"kamil.ogorek@gmail.com"},"license":"MIT","_id":"pglite-server@0.1.3","maintainers":[{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"}],"homepage":"https://github.com/kamilogorek/pglite-server#readme","bugs":{"url":"https://github.com/kamilogorek/pglite-server/issues"},"dist":{"shasum":"f36cfd4bceda806d54bce585f6a1e69b34afc99f","tarball":"https://registry.npmjs.org/pglite-server/-/pglite-server-0.1.3.tgz","fileCount":4,"integrity":"sha512-corJYDPPMVkV1CR2t4V1MWYIn4GAfOyC6nKW48fEMf2mI0IieUao7z1cXqZgfGNomIT/EirltvXR/3JD77rhzg==","signatures":[{"sig":"MEUCIQDZwBovbGE2te+TFrBfmlT41eJuDtfPPQ55y2yYxGGpEQIgKQ6S92Uf1VjMymqA9AdccedwzuD1EjX8H+2xNu6SgEk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13279},"type":"module","engines":{"node":">=20"},"exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"gitHead":"cbc7c639fe2dcece2f31ada7cf96e906e390b001","scripts":{"test":"bun run test/main.ts && bun run test/invalid-input.ts","build":"tsup src/index.ts --format esm --dts"},"_npmUser":{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"},"repository":{"url":"git+https://github.com/kamilogorek/pglite-server.git","type":"git"},"_npmVersion":"10.7.0","description":"Wire Protocol Server for PGlite","directories":{},"_nodeVersion":"20.15.1","_hasShrinkwrap":false,"devDependencies":{"pg":"^8.11.5","tsup":"^8.0.2","@types/pg":"^8.11.4","typescript":"^5.4.4","@types/node":"^20.12.4","@electric-sql/pglite":"^0.1.2"},"_npmOperationalInternal":{"tmp":"tmp/pglite-server_0.1.3_1720799049526_0.05725905081140725","host":"s3://npm-registry-packages"}},"0.1.4":{"name":"pglite-server","version":"0.1.4","author":{"name":"Kamil Ogórek","email":"kamil.ogorek@gmail.com"},"license":"MIT","_id":"pglite-server@0.1.4","maintainers":[{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"}],"homepage":"https://github.com/kamilogorek/pglite-server#readme","bugs":{"url":"https://github.com/kamilogorek/pglite-server/issues"},"dist":{"shasum":"da16cc6670dcf2de3dfe02212f7ebc4d5d5b963e","tarball":"https://registry.npmjs.org/pglite-server/-/pglite-server-0.1.4.tgz","fileCount":5,"integrity":"sha512-qcZZ5mu+UiLBHa6cHsFYqT6U6wvodg3HNO+kMFCLYlWWG7s1zm1BfO5MWb0yS0OZPgthJklzYz8NQJRujrZKZQ==","signatures":[{"sig":"MEYCIQDBcQYqz6L8IKOikMYOGmvcSc4BPq6AeCCfewlxlEtsswIhANC35VXmJtutQ7DAEfs+G95GGG2n8DghKYfOHWk24sNK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14546},"type":"module","engines":{"node":">=20"},"exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"gitHead":"00284bbffb6736f0beb901c64b5d711999872a6d","scripts":{"test":"bun run test/main.ts && bun run test/invalid-input.ts","build":"tsup src/index.ts --format esm --dts"},"_npmUser":{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"},"repository":{"url":"git+https://github.com/kamilogorek/pglite-server.git","type":"git"},"_npmVersion":"10.9.0","description":"Wire Protocol Server for PGlite","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":false,"devDependencies":{"pg":"^8.13.1","tsup":"^8.3.5","@types/pg":"^8.11.10","typescript":"^5.7.2","@types/node":"^22.9.3","@electric-sql/pglite":"^0.2.13"},"_npmOperationalInternal":{"tmp":"tmp/pglite-server_0.1.4_1732484261874_0.2409316061298994","host":"s3://npm-registry-packages"}},"0.1.5":{"name":"pglite-server","description":"Wire Protocol Server for PGlite","version":"0.1.5","repository":{"type":"git","url":"git+https://github.com/kamilogorek/pglite-server.git"},"author":{"name":"Kamil Ogórek","email":"kamil.ogorek@gmail.com"},"license":"MIT","type":"module","exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"engines":{"node":">=20"},"scripts":{"build":"tsup src/index.ts --format esm --dts","test":"bun run test/main.ts && bun run test/invalid-input.ts"},"peerDependencies":{"@electric-sql/pglite":">=0.2.0"},"devDependencies":{"@electric-sql/pglite":"^0.3.15","@types/node":"^25.2.1","@types/pg":"^8.16.0","pg":"^8.18.0","tsup":"^8.5.1","typescript":"^5.9.3"},"_id":"pglite-server@0.1.5","gitHead":"7d93f35a1c22d0915e04cffe5febb920e5ee80ac","bugs":{"url":"https://github.com/kamilogorek/pglite-server/issues"},"homepage":"https://github.com/kamilogorek/pglite-server#readme","_nodeVersion":"22.18.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-vJe8NVbrwSN7g0v6BaHtvVxSO9OiYw6JhMfAPWm00eI/eNVmfFfLLoZDQONBlsK/uASca9kvRWnrvB6WJnVIJg==","shasum":"5fe9382e475cebe0fd477925e47a378e7d8222d3","tarball":"https://registry.npmjs.org/pglite-server/-/pglite-server-0.1.5.tgz","fileCount":5,"unpackedSize":15214,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCK9lHxvd2pidfvyMn7LFZaJkzxksV54axKOaHMlFwk8QIhAMTuKLlEDqly2xifQjgGp73oDiJ1567nBPk+9YGONKDh"}]},"_npmUser":{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"},"directories":{},"maintainers":[{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pglite-server_0.1.5_1770478943008_0.9416979308286328"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-06T07:57:25.458Z","modified":"2026-02-07T15:42:23.267Z","0.1.0":"2024-04-06T07:57:25.617Z","0.1.1":"2024-04-06T08:11:06.569Z","0.1.2":"2024-05-07T06:58:10.504Z","0.1.3":"2024-07-12T15:44:09.712Z","0.1.4":"2024-11-24T21:37:42.033Z","0.1.5":"2026-02-07T15:42:23.150Z"},"bugs":{"url":"https://github.com/kamilogorek/pglite-server/issues"},"author":{"name":"Kamil Ogórek","email":"kamil.ogorek@gmail.com"},"license":"MIT","homepage":"https://github.com/kamilogorek/pglite-server#readme","repository":{"type":"git","url":"git+https://github.com/kamilogorek/pglite-server.git"},"description":"Wire Protocol Server for PGlite","maintainers":[{"name":"kamilogorek","email":"kamil.ogorek@gmail.com"}],"readme":"# Wire Protocol Server for PGlite\n\n> [!TIP]\n> If you are looking for more versatile and feature-rich solution, check [`pg-gateway`](https://github.com/supabase-community/pg-gateway) from [Supabase](https://supabase.com/) instead.\n\nA spare-time attempt to understand Postgres Wire Protocol and expose a TCP server,\nthat can be used to redirect all client requests to [PGlite](https://github.com/electric-sql/pglite) instance.\n\nThis can be used to connect to a running instance via `pgsql` or in the future,\nrun a https://postgrest.org/ on top of said `PGlite` instance and automatically create a temporary, in-memory API endpoints.\n\n- https://www.postgresql.org/docs/current/protocol.html\n- https://www.postgresql.org/docs/current/protocol-message-formats.html\n\nIt intercepts `SSLRequest` and `StartupMessage` messages to fake authentication flow and redirects all remaining packets directly to `PGlite` instance.\n\n## Usage\n\n```sh\nnpm install pglite-server\n```\n\n```ts\nimport { PGlite } from \"@electric-sql/pglite\";\nimport { createServer } from \"pglite-server\";\n\nconst db = new PGlite();\nawait db.waitReady;\n\nawait db.exec(`\n  create table if not exists test (id serial primary key, name text);\n  insert into test (name) values ('foo'), ('bar'), ('baz');\n`);\n\nconst PORT = 5432;\nconst pgServer = createServer(db);\n\npgServer.listen(PORT, () => {\n  console.log(`Server bound to port ${PORT}`);\n});\n```\n\n```\n$ psql -h localhost -p 5432 -U postgres\npostgres=> select * from test;\npostgres=> \\q\n```\n\nor without `db.exec` used above\n\n```\n$ psql -h localhost -p 5432 -U postgres\npostgres=> create table if not exists test (id serial primary key, name text);\npostgres=> insert into test (name) values ('foo'), ('bar'), ('baz');\npostgres=> select * from test;\npostgres=> \\q\n```\n\n### Using with `pg` client\n\nSee `test/main.ts` for more detailed example, but here's a quick excerpt:\n\n```ts\nimport { PGlite } from \"@electric-sql/pglite\";\nimport { Client } from \"pg\";\nimport { createServer } from \"pglite-server\";\n\nconst PORT = 5432;\nconst db = new PGlite();\nawait db.waitReady;\nawait db.exec(`\n  create table if not exists test (id serial primary key, name text);\n  insert into test (name) values ('foo'), ('bar'), ('baz');\n`);\n\nconst pgServer = createServer(db);\n\npgServer.listen(PORT, async () => {\n  const client = new Client({\n    host: \"localhost\",\n    port: PORT,\n    database: \"postgres\",\n    user: \"postgres\",\n  });\n  await client.connect();\n  const res = await client.query(\"select * from test\");\n  console.log(res.rows);\n});\n```\n\n### Options\n\nIf you want to see all debug output of the network communication, set `logLevel` to `Debug`:\n\n```ts\nimport { createServer, LogLevel } from \"pglite-server\";\n\nconst pgServer = createServer(db, {\n  logLevel: LogLevel.Debug,\n});\n\npgServer.listen();\n```\n\n## Developing\n\nThis repo uses https://bun.sh/ because I don't want to spend time fighting with Node and TypeScript tooling.\n\nMake sure that it's available before running tests, or write your own ts-loader config, ts-node, or whatever people use these days.\n\n```sh\nbun run test\nbun run build\n```\n\n## Debugging\n\nDebugging network traffic with `tshark` - https://zignar.net/2022/09/24/using-tshark-to-monitor-pg-traffic/\n\n```sh\nbrew install wireshark\n```\n\n```sh\ntshark -i lo -f 'tcp port 5432' -d tcp.port==5432,pgsql -T fields -e pgsql.length -e pgsql.type -e pgsql.query\n```\n\n## Publishing\n\n```\nnpm version <patch|minor|major>\ngit push\nbun run build\nnpm publish\n```\n","readmeFilename":"README.md"}