litepg 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/bin/litepg.js +49 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# litepg
|
|
2
|
+
|
|
3
|
+
A PostgreSQL-compatible database in one binary, backed by an embedded
|
|
4
|
+
SQLite-format engine. Speaks the PostgreSQL wire protocol, so `psql`,
|
|
5
|
+
`node-postgres`, `asyncpg`, Prisma, Drizzle and friends connect as they
|
|
6
|
+
would to PostgreSQL. With `--supabase` it also serves PostgREST-compatible
|
|
7
|
+
REST and GoTrue-compatible Auth APIs over the same database, so a
|
|
8
|
+
supabase-js client can point at it.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
pnpm dlx litepg mydb.db --server # PostgreSQL on 127.0.0.1, first free port from 5432 up
|
|
12
|
+
pnpm dlx litepg mydb.db --supabase # the same, plus REST and Auth on the first free port from 54321 up
|
|
13
|
+
pnpm dlx litepg mydb.db # an interactive SQL shell
|
|
14
|
+
pnpm dlx litepg :memory: "SELECT 1 + 1" # one statement, in memory
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`--server=0.0.0.0:5432` (or `--server=5433`, a port on the loopback) binds
|
|
18
|
+
exactly that address. `--supabase` prints the JWT secret and the `anon` and
|
|
19
|
+
`service_role` keys for the run; pass `--jwt-secret` or set
|
|
20
|
+
`AUTH_JWT_SECRET` to keep them stable across runs.
|
|
21
|
+
|
|
22
|
+
This package is a shim that runs the prebuilt binary for your platform
|
|
23
|
+
(Apple Silicon macOS, and Linux on x64 and arm64; there is no Intel macOS
|
|
24
|
+
build). Source, compatibility notes and issues:
|
|
25
|
+
<https://github.com/olirice/litepg>.
|
package/bin/litepg.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The `litepg` npm shim: find the platform package that carries the binary
|
|
3
|
+
// for this machine and exec it with the user's arguments. See npm/README.md
|
|
4
|
+
// for the package layout and why there is no postinstall step.
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const { spawnSync } = require("node:child_process");
|
|
8
|
+
const path = require("node:path");
|
|
9
|
+
|
|
10
|
+
const PLATFORMS = {
|
|
11
|
+
"darwin-arm64": "litepg-darwin-arm64",
|
|
12
|
+
"linux-arm64": "litepg-linux-arm64",
|
|
13
|
+
"linux-x64": "litepg-linux-x64",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const key = `${process.platform}-${process.arch}`;
|
|
17
|
+
const pkg = PLATFORMS[key];
|
|
18
|
+
if (!pkg) {
|
|
19
|
+
console.error(
|
|
20
|
+
`litepg: no prebuilt binary for ${key}. Prebuilt platforms: ${Object.keys(PLATFORMS).join(", ")}.\n` +
|
|
21
|
+
"Build from source instead: https://github.com/olirice/litepg (cargo build --release -p litepg).",
|
|
22
|
+
);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let binary;
|
|
27
|
+
try {
|
|
28
|
+
// Resolving the platform package's package.json (a JS-resolvable file)
|
|
29
|
+
// and stepping to bin/ beside it works whether npm hoisted the package
|
|
30
|
+
// or pnpm kept it in its own store directory.
|
|
31
|
+
binary = path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin", "litepg");
|
|
32
|
+
} catch {
|
|
33
|
+
console.error(
|
|
34
|
+
`litepg: the platform package ${pkg} is not installed. It is an optional dependency of litepg; ` +
|
|
35
|
+
"reinstall without --no-optional, or check that your package manager allows optional dependencies.",
|
|
36
|
+
);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
41
|
+
if (result.error) {
|
|
42
|
+
console.error(`litepg: could not start ${binary}: ${result.error.message}`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
if (result.signal) {
|
|
46
|
+
// Mirror the signal the binary died from, the way a shell would report it.
|
|
47
|
+
process.kill(process.pid, result.signal);
|
|
48
|
+
}
|
|
49
|
+
process.exit(result.status ?? 1);
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "litepg",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "PostgreSQL-compatible embedded database with optional Supabase REST and Auth APIs, as a single binary",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/olirice/litepg.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/olirice/litepg",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"postgres",
|
|
13
|
+
"postgresql",
|
|
14
|
+
"sqlite",
|
|
15
|
+
"embedded",
|
|
16
|
+
"database",
|
|
17
|
+
"supabase",
|
|
18
|
+
"postgrest"
|
|
19
|
+
],
|
|
20
|
+
"bin": {
|
|
21
|
+
"litepg": "bin/litepg.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin/litepg.js",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"litepg-darwin-arm64": "0.1.0",
|
|
32
|
+
"litepg-linux-arm64": "0.1.0",
|
|
33
|
+
"litepg-linux-x64": "0.1.0"
|
|
34
|
+
}
|
|
35
|
+
}
|