Skip to content

Commit fe0e2d3

Browse files
author
Michael Barnes
authored
Merge pull request #52 from powersync-community/minor-updates
Minor updates
2 parents baa4ca8 + 81fb234 commit fe0e2d3

File tree

4 files changed

+118
-31
lines changed

4 files changed

+118
-31
lines changed

Caddyfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# global options
2+
{
3+
admin off # there's no need for the admin api in railway's environment
4+
persist_config off # storage isn't persistent anyway
5+
auto_https off # railway handles https for us, this would cause issues if left enabled
6+
# runtime logs
7+
log {
8+
format json # set runtime log format to json mode
9+
}
10+
# server options
11+
servers {
12+
trusted_proxies static private_ranges 100.0.0.0/8 # trust railway's proxy
13+
}
14+
}
15+
16+
# site block, listens on the $PORT environment variable, automatically assigned by railway
17+
:{$PORT:3000} {
18+
# access logs
19+
log {
20+
format json # set access log format to json mode
21+
}
22+
23+
# health check for railway
24+
rewrite /health /*
25+
26+
# serve from the 'dist' folder (Vite builds into the 'dist' folder)
27+
root * dist
28+
29+
# enable gzipping responses
30+
encode gzip
31+
32+
# serve files from 'dist'
33+
file_server
34+
35+
# if path doesn't exist, redirect it to 'index.html' for client side routing
36+
try_files {path} /index.html
37+
}

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Use the Node alpine official image
2+
# https://hub.docker.com/_/node
3+
FROM node:lts-alpine AS build
4+
5+
# Set config
6+
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
7+
ENV NPM_CONFIG_FUND=false
8+
9+
# Create and change to the app directory.
10+
WORKDIR /app
11+
12+
# Copy the files to the container image
13+
COPY package*.json ./
14+
15+
# Install packages
16+
RUN npm ci
17+
18+
# Copy local code to the container image.
19+
COPY . ./
20+
21+
# Build the app.
22+
RUN npm run build
23+
24+
# Use the Caddy image
25+
FROM caddy
26+
27+
# Create and change to the app directory.
28+
WORKDIR /app
29+
30+
# Copy Caddyfile to the container image.
31+
COPY Caddyfile ./
32+
33+
# Copy local code to the container image.
34+
RUN caddy fmt Caddyfile --overwrite
35+
36+
# Copy files to the container image.
37+
COPY --from=build /app/dist ./dist
38+
39+
# Use Caddy to run/serve the app
40+
CMD ["caddy", "run", "--config", "Caddyfile", "--adapter", "caddyfile"]

eslint.config.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,28 @@ import globals from 'globals'
33
import reactHooks from 'eslint-plugin-react-hooks'
44
import reactRefresh from 'eslint-plugin-react-refresh'
55
import tseslint from 'typescript-eslint'
6-
import { globalIgnores } from 'eslint/config'
6+
import { defineConfig, globalIgnores } from 'eslint/config'
77

8-
export default tseslint.config([
8+
export default defineConfig([
99
globalIgnores(['dist']),
10+
js.configs.recommended,
11+
...tseslint.configs.recommended,
1012
{
1113
files: ['**/*.{ts,tsx}'],
12-
extends: [
13-
js.configs.recommended,
14-
tseslint.configs.recommended,
15-
reactHooks.configs['recommended-latest'],
16-
reactRefresh.configs.vite,
17-
],
14+
plugins: {
15+
'react-hooks': reactHooks,
16+
'react-refresh': reactRefresh,
17+
},
1818
languageOptions: {
1919
ecmaVersion: 2020,
2020
globals: globals.browser,
2121
},
22+
rules: {
23+
...reactHooks.configs.recommended.rules,
24+
'react-refresh/only-export-components': [
25+
'warn',
26+
{ allowConstantExport: true },
27+
],
28+
},
2229
},
2330
])

src/powersync/System.ts

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import {
22
createBaseLogger,
33
LogLevel,
44
PowerSyncDatabase,
5+
SyncClientImplementation,
6+
WASQLiteOpenFactory,
7+
WASQLiteVFS
58
} from "@powersync/web";
69
import { AppSchema } from "./AppSchema";
710
import { connector } from "./SupabaseConnector";
@@ -11,17 +14,17 @@ logger.useDefaults();
1114
logger.setLevel(LogLevel.DEBUG);
1215

1316
/**
14-
* Default configuration - uses IndexedDB storage
17+
* Default configuration AccessHandlePoolVFS - uses IndexedDB
1518
* ✅ Use this for: Simple setup, most browsers
1619
* ❌ Avoid if: You need Safari support or have stability issues
1720
*/
18-
export const powerSync = new PowerSyncDatabase({
19-
schema: AppSchema,
20-
database: {
21-
dbFilename: 'example.db'
22-
},
23-
logger: logger
24-
});
21+
// export const powerSync = new PowerSyncDatabase({
22+
// schema: AppSchema,
23+
// database: {
24+
// dbFilename: 'example.db'
25+
// },
26+
// logger: logger
27+
// });
2528

2629
/**
2730
* Alternative configuration with OPFS storage (Origin Private File System)
@@ -41,20 +44,20 @@ export const powerSync = new PowerSyncDatabase({
4144
*
4245
* 📚 Learn more: https://docs.powersync.com/client-sdk-references/javascript-web#sqlite-virtual-file-systems
4346
*/
44-
// export const powerSync = new PowerSyncDatabase({
45-
// database: new WASQLiteOpenFactory({
46-
// dbFilename: "exampleVFS.db",
47-
// vfs: WASQLiteVFS.OPFSCoopSyncVFS, // Use AccessHandlePoolVFS for single-tab only
48-
// flags: {
49-
// enableMultiTabs: typeof SharedWorker !== "undefined",
50-
// },
51-
// }),
52-
// flags: {
53-
// enableMultiTabs: typeof SharedWorker !== "undefined",
54-
// },
55-
// schema: AppSchema,
56-
// logger: logger,
57-
// });
47+
export const powerSync = new PowerSyncDatabase({
48+
database: new WASQLiteOpenFactory({
49+
dbFilename: "exampleVFS.db",
50+
vfs: WASQLiteVFS.OPFSCoopSyncVFS, // Use AccessHandlePoolVFS for single-tab only
51+
flags: {
52+
enableMultiTabs: typeof SharedWorker !== "undefined",
53+
},
54+
}),
55+
flags: {
56+
enableMultiTabs: typeof SharedWorker !== "undefined",
57+
},
58+
schema: AppSchema,
59+
logger: logger,
60+
});
5861

5962
/**
6063
* Quick Decision Guide:
@@ -69,4 +72,4 @@ export const powerSync = new PowerSyncDatabase({
6972
await connector.signInAnonymously();
7073

7174
// Establish connection between PowerSync and the Supabase connector
72-
powerSync.connect(connector);
75+
powerSync.connect(connector, { clientImplementation: SyncClientImplementation.RUST });

0 commit comments

Comments
 (0)