Skip to content

Commit 73620aa

Browse files
committed
fix wildcard
1 parent 74a9aa1 commit 73620aa

File tree

4 files changed

+141
-9
lines changed

4 files changed

+141
-9
lines changed

apps/db-service/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ AWS_SECRET_ACCESS_KEY=minioadmin
77
# Only if you need to test against a bucket hosted in AWS S3
88
# AWS_SESSION_TOKEN=<aws-session-token>
99
AWS_ENDPOINT_URL_S3=http://minio:9000
10-
DOMAIN=*.db.example.com
10+
WILDCARD_DOMAIN=db.example.com

apps/db-service/scripts/generate-certs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
set -o pipefail
55

66
S3FS_MOUNT=${S3FS_MOUNT:=.}
7-
DOMAIN="${DOMAIN:=*.db.example.com}"
7+
DOMAIN="*.${WILDCARD_DOMAIN:=db.example.com}"
88
CERT_DIR="$S3FS_MOUNT/tls"
99

1010
mkdir -p $CERT_DIR

apps/db-service/src/index.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PGlite, PGliteInterface } from '@electric-sql/pglite'
22
import { vector } from '@electric-sql/pglite/vector'
3-
import { mkdir, readFile, access } from 'node:fs/promises'
3+
import { mkdir, readFile, access, rm } from 'node:fs/promises'
44
import net from 'node:net'
55
import { createReadStream } from 'node:fs'
66
import { pipeline } from 'node:stream/promises'
@@ -111,12 +111,24 @@ const server = net.createServer((socket) => {
111111
// Create a directory for the database
112112
await mkdir(dbPath, { recursive: true });
113113

114-
// Extract the .tar.gz file
115-
await pipeline(
116-
createReadStream(dumpPath),
117-
createGunzip(),
118-
extract({ cwd: dbPath, })
119-
);
114+
try {
115+
// Extract the .tar.gz file
116+
await pipeline(
117+
createReadStream(dumpPath),
118+
createGunzip(),
119+
extract({ cwd: dbPath })
120+
);
121+
} catch (error) {
122+
console.error(error);
123+
await rm(dbPath, { recursive: true, force: true }); // Clean up the partially created directory
124+
connection.sendError({
125+
severity: 'FATAL',
126+
code: 'XX000',
127+
message: `Error extracting database: ${(error as Error).message}`,
128+
});
129+
connection.socket.end();
130+
return;
131+
}
120132
}
121133

122134
db = new PGlite(dbPath, {

package-lock.json

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)