@hatk/hatk 0.0.1-alpha.18 → 0.0.1-alpha.19

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/dist/main.js CHANGED
@@ -113,7 +113,31 @@ if (config.oauth) {
113
113
  logMemory('before-server');
114
114
  // 5. Start server immediately (don't wait for backfill)
115
115
  const collectionSet = new Set(collections);
116
- startServer(config.port, collections, config.publicDir, config.oauth, config.admins);
116
+ const backfillOpts = {
117
+ pdsUrl: relayHttpUrl(config.relay),
118
+ plcUrl: config.plc,
119
+ collections: collectionSet,
120
+ config: config.backfill,
121
+ };
122
+ function runBackfillAndRestart() {
123
+ runBackfill(backfillOpts)
124
+ .then((recordCount) => {
125
+ log('[main] Backfill complete, rebuilding FTS indexes...');
126
+ return rebuildAllIndexes(collections).then(() => recordCount);
127
+ })
128
+ .then((recordCount) => {
129
+ log('[main] FTS indexes ready');
130
+ if (recordCount > 0) {
131
+ logMemory('after-backfill');
132
+ log('[main] Restarting to reclaim memory...');
133
+ process.exit(1);
134
+ }
135
+ })
136
+ .catch((err) => {
137
+ console.error('[main] Backfill error:', err.message);
138
+ });
139
+ }
140
+ startServer(config.port, collections, config.publicDir, config.oauth, config.admins, undefined, runBackfillAndRestart);
117
141
  log(`\nhatk running:`);
118
142
  log(` Relay: ${config.relay}`);
119
143
  log(` Database: ${config.database}`);
@@ -137,27 +161,7 @@ startIndexer({
137
161
  ftsRebuildInterval: config.ftsRebuildInterval,
138
162
  });
139
163
  // 7. Run backfill in background
140
- runBackfill({
141
- pdsUrl: relayHttpUrl(config.relay),
142
- plcUrl: config.plc,
143
- collections: collectionSet,
144
- config: config.backfill,
145
- })
146
- .then((recordCount) => {
147
- log('[main] Backfill complete, rebuilding FTS indexes...');
148
- return rebuildAllIndexes(collections).then(() => recordCount);
149
- })
150
- .then((recordCount) => {
151
- log('[main] FTS indexes ready');
152
- if (recordCount > 0) {
153
- logMemory('after-backfill');
154
- log('[main] Restarting to reclaim memory...');
155
- process.exit(1);
156
- }
157
- })
158
- .catch((err) => {
159
- console.error('[main] Backfill error:', err.message);
160
- });
164
+ runBackfillAndRestart();
161
165
  // Graceful shutdown
162
166
  process.on('SIGTERM', () => {
163
167
  log('[main] Received SIGTERM, shutting down...');
package/dist/server.d.ts CHANGED
@@ -2,5 +2,5 @@ import { type Server, type IncomingMessage } from 'node:http';
2
2
  import type { OAuthConfig } from './config.ts';
3
3
  export declare function startServer(port: number, collections: string[], publicDir: string | null, oauth: OAuthConfig | null, admins?: string[], resolveViewer?: (req: IncomingMessage) => {
4
4
  did: string;
5
- } | null): Server;
5
+ } | null, onResync?: () => void): Server;
6
6
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAmD3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA2B9C,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAAE,EACrB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,MAAM,GAAE,MAAM,EAAO,EACrB,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAC/D,MAAM,CA28BR"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAmD3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA2B9C,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAAE,EACrB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,MAAM,GAAE,MAAM,EAAO,EACrB,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EAChE,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,MAAM,CA28BR"}
package/dist/server.js CHANGED
@@ -39,7 +39,7 @@ function readBodyRaw(req) {
39
39
  req.on('error', reject);
40
40
  });
41
41
  }
42
- export function startServer(port, collections, publicDir, oauth, admins = [], resolveViewer) {
42
+ export function startServer(port, collections, publicDir, oauth, admins = [], resolveViewer, onResync) {
43
43
  const coreXrpc = (method) => `/xrpc/dev.hatk.${method}`;
44
44
  const devMode = process.env.DEV_MODE === '1';
45
45
  function requireAdmin(viewer, res) {
@@ -450,9 +450,10 @@ export function startServer(port, collections, publicDir, oauth, admins = [], re
450
450
  }
451
451
  for (const did of repoList) {
452
452
  await setRepoStatus(did, 'pending');
453
- triggerAutoBackfill(did);
454
453
  }
455
454
  jsonResponse(res, { resyncing: repoList.length });
455
+ if (onResync)
456
+ onResync();
456
457
  return;
457
458
  }
458
459
  // POST /admin/repos/remove — remove DIDs from tracking
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatk/hatk",
3
- "version": "0.0.1-alpha.18",
3
+ "version": "0.0.1-alpha.19",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "hatk": "dist/cli.js"