@xtr-dev/rondevu-server 0.5.1 → 0.5.6
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/.github/workflows/claude-code-review.yml +57 -0
- package/.github/workflows/claude.yml +50 -0
- package/.idea/modules.xml +8 -0
- package/.idea/rondevu-server.iml +8 -0
- package/.idea/workspace.xml +17 -0
- package/README.md +80 -199
- package/build.js +4 -1
- package/dist/index.js +2755 -1448
- package/dist/index.js.map +4 -4
- package/migrations/fresh_schema.sql +36 -41
- package/package.json +10 -4
- package/src/app.ts +38 -18
- package/src/config.ts +155 -9
- package/src/crypto.ts +361 -263
- package/src/index.ts +20 -25
- package/src/rpc.ts +658 -405
- package/src/storage/d1.ts +312 -263
- package/src/storage/factory.ts +69 -0
- package/src/storage/hash-id.ts +13 -9
- package/src/storage/memory.ts +559 -0
- package/src/storage/mysql.ts +588 -0
- package/src/storage/postgres.ts +595 -0
- package/src/storage/schemas/mysql.sql +59 -0
- package/src/storage/schemas/postgres.sql +64 -0
- package/src/storage/sqlite.ts +303 -269
- package/src/storage/types.ts +113 -113
- package/src/worker.ts +15 -34
- package/tests/integration/api.test.ts +395 -0
- package/tests/integration/setup.ts +170 -0
- package/wrangler.toml +25 -26
- package/ADVANCED.md +0 -502
package/src/index.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { serve } from '@hono/node-server';
|
|
2
2
|
import { createApp } from './app.ts';
|
|
3
|
-
import { loadConfig } from './config.ts';
|
|
4
|
-
import {
|
|
3
|
+
import { loadConfig, runCleanup } from './config.ts';
|
|
4
|
+
import { createStorage } from './storage/factory.ts';
|
|
5
5
|
import { Storage } from './storage/types.ts';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Main entry point for the standalone Node.js server
|
|
9
|
-
*/
|
|
10
7
|
async function main() {
|
|
11
8
|
const config = loadConfig();
|
|
12
9
|
|
|
@@ -14,32 +11,30 @@ async function main() {
|
|
|
14
11
|
console.log('Configuration:', {
|
|
15
12
|
port: config.port,
|
|
16
13
|
storageType: config.storageType,
|
|
17
|
-
storagePath: config.storagePath,
|
|
14
|
+
storagePath: config.storageType === 'sqlite' ? config.storagePath : undefined,
|
|
15
|
+
databaseUrl: config.databaseUrl ? '[configured]' : undefined,
|
|
16
|
+
dbPoolSize: ['mysql', 'postgres'].includes(config.storageType) ? config.dbPoolSize : undefined,
|
|
18
17
|
offerDefaultTtl: `${config.offerDefaultTtl}ms`,
|
|
19
|
-
offerMaxTtl: `${config.offerMaxTtl}ms`,
|
|
20
|
-
offerMinTtl: `${config.offerMinTtl}ms`,
|
|
21
18
|
cleanupInterval: `${config.cleanupInterval}ms`,
|
|
22
|
-
maxOffersPerRequest: config.maxOffersPerRequest,
|
|
23
|
-
corsOrigins: config.corsOrigins,
|
|
24
19
|
version: config.version,
|
|
25
20
|
});
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
22
|
+
const storage: Storage = await createStorage({
|
|
23
|
+
type: config.storageType,
|
|
24
|
+
masterEncryptionKey: config.masterEncryptionKey,
|
|
25
|
+
sqlitePath: config.storagePath,
|
|
26
|
+
connectionString: config.databaseUrl,
|
|
27
|
+
poolSize: config.dbPoolSize,
|
|
28
|
+
});
|
|
29
|
+
console.log(`Using ${config.storageType} storage`);
|
|
35
30
|
|
|
36
|
-
//
|
|
37
|
-
const
|
|
31
|
+
// Periodic cleanup
|
|
32
|
+
const cleanupTimer = setInterval(async () => {
|
|
38
33
|
try {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
console.log(`Cleanup:
|
|
34
|
+
const result = await runCleanup(storage, Date.now());
|
|
35
|
+
const total = result.offers + result.credentials + result.rateLimits + result.nonces;
|
|
36
|
+
if (total > 0) {
|
|
37
|
+
console.log(`Cleanup: ${result.offers} offers, ${result.credentials} credentials, ${result.rateLimits} rate limits, ${result.nonces} nonces`);
|
|
43
38
|
}
|
|
44
39
|
} catch (err) {
|
|
45
40
|
console.error('Cleanup error:', err);
|
|
@@ -59,7 +54,7 @@ async function main() {
|
|
|
59
54
|
// Graceful shutdown handler
|
|
60
55
|
const shutdown = async () => {
|
|
61
56
|
console.log('\nShutting down gracefully...');
|
|
62
|
-
clearInterval(
|
|
57
|
+
clearInterval(cleanupTimer);
|
|
63
58
|
await storage.close();
|
|
64
59
|
process.exit(0);
|
|
65
60
|
};
|