@cloud-cli/d0 1.6.2 → 1.7.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/Dockerfile CHANGED
@@ -9,6 +9,9 @@ RUN pnpm i && pnpm build && rm -rf node_modules/ src/ && pnpm store prune
9
9
  FROM ghcr.io/cloud-cli/node:latest
10
10
 
11
11
  ENV NODE_ENV=production
12
+ ENV DATA_PATH=/home/app/data
12
13
  WORKDIR /home/app
13
- COPY --from=builder /home/app/ ./
14
- RUN pnpm install --prod
14
+ COPY --from=builder --chown=node:node /home/app/ ./
15
+ RUN pnpm install --prod --frozen-lockfile && pnpm rebuild better-sqlite3
16
+ RUN mkdir -p /home/app/data && chown node:node /home/app/data
17
+ VOLUME ["/home/app/data"]
package/README.md CHANGED
@@ -63,7 +63,7 @@ Otherwise, it will be available at `http://localhost:PORT/` and serve a single d
63
63
  | Variable | Description |
64
64
  |-|-|
65
65
  | PORT | HTTP port |
66
- | DATA_PATH | Path to a folder where the database files are stored |
66
+ | DATA_PATH | Path to a folder where the database files are stored (default: `/home/app/data` in Docker) |
67
67
  | BASE_DOMAIN | Root domain to use in a multi-db server, e.g. `.example.com` |
68
68
  | MAX_DATABASES | Maximum number of database connections kept open (default: `32`) |
69
69
  | MAX_BODY_BYTES | Maximum JSON request size (default: `1048576`) |
package/console.html CHANGED
@@ -55,6 +55,7 @@
55
55
  padding: 10px 14px;
56
56
  }
57
57
  .brand { color: var(--accent); font-weight: 700; letter-spacing: .08em; }
58
+ .brand-mark { border-radius: 5px; height: 24px; width: 24px; }
58
59
  .db-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
59
60
  .spacer { flex: 1; }
60
61
  .workspace {
@@ -221,6 +222,7 @@
221
222
  </script>
222
223
  <div class="shell">
223
224
  <header class="topbar">
225
+ <img class="brand-mark" src="./logo.svg" alt="d0" />
224
226
  <span class="brand">D0</span>
225
227
  <span class="db-name">{{ name || 'database' }}</span>
226
228
  <span class="spacer"></span>
@@ -248,7 +250,7 @@
248
250
  <section class="panel editor-panel">
249
251
  <div class="editor">
250
252
  <div class="panel-title">Query</div>
251
- <code-editor nolines="1" language="sql" bind-value="query" on-change="setQuery($event.target.value)" on-keyup="onKeyUp($event)"></code-editor>
253
+ <code-editor nolines="1" nostatus="1" theme="a11y-dark" language="sql" bind-value="query" on-change="setQuery($event.target.value)" on-keyup="onKeyUp($event)"></code-editor>
252
254
  <div class="editor-actions">
253
255
  <button class="run" type="button" on-click="runQuery()">Run query</button>
254
256
  </div>
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createServer } from 'node:http';
2
+ import { mkdirSync } from 'node:fs';
2
3
  import { readFile } from 'node:fs/promises';
3
4
  import SQLite from 'better-sqlite3';
4
5
  import { join } from 'node:path';
@@ -11,6 +12,7 @@ const maxDatabases = Math.max(1, Number.parseInt(process.env.MAX_DATABASES || '3
11
12
  const maxBodyBytes = Math.max(1, Number.parseInt(process.env.MAX_BODY_BYTES || '1048576', 10) || 1048576);
12
13
  const slowQueryMs = Math.max(0, Number.parseInt(process.env.SLOW_QUERY_MS || '1000', 10) || 1000);
13
14
  const databases = new Map();
15
+ mkdirSync(dataPath, { recursive: true });
14
16
  export function getDatabase(file) {
15
17
  const fullPath = join(dataPath, file);
16
18
  const cached = databases.get(fullPath);
@@ -75,6 +77,10 @@ export async function handleRequest(request, response, db) {
75
77
  const consolePage = await readFile('./console.html', 'utf8');
76
78
  response.writeHead(200, { 'content-type': 'text/html' }).end(consolePage);
77
79
  return;
80
+ case 'GET /logo.svg':
81
+ const logo = await readFile('./logo.svg', 'utf8');
82
+ response.writeHead(200, { 'content-type': 'image/svg+xml' }).end(logo);
83
+ return;
78
84
  case 'GET /index.mjs':
79
85
  return onEsModule(request, response);
80
86
  case 'GET /schema':
package/logo.svg ADDED
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" role="img" aria-labelledby="title desc">
2
+ <title id="title">d0</title>
3
+ <desc id="desc">A simple stacked database mark with a zero-shaped center.</desc>
4
+ <rect width="256" height="256" rx="56" fill="#101316" />
5
+ <path fill="#8bd5ca" d="M48 72c0-24 36-40 80-40s80 16 80 40v112c0 24-36 40-80 40s-80-16-80-40V72Zm24 0v112c0 8 22 16 56 16s56-8 56-16V72c-16 10-38 16-56 16S88 82 72 72Zm56-16c-34 0-56 10-56 16s22 16 56 16 56-10 56-16-22-16-56-16Z" />
6
+ <path fill="#101316" d="M104 120h24c22 0 36 12 36 32s-14 32-36 32h-24v-16h24c11 0 18-5 18-16s-7-16-18-16h-24v-16Z" />
7
+ <path fill="#101316" d="M88 120h16v64H88z" />
8
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-cli/d0",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",