From 3d9d6f46d122f1968686cbdb4e4932d8754a1ec8 Mon Sep 17 00:00:00 2001 From: atecnoco-arch Date: Fri, 17 Apr 2026 14:52:32 +0300 Subject: [PATCH 1/3] Create index.ts --- plugins/replication/index.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 plugins/replication/index.ts diff --git a/plugins/replication/index.ts b/plugins/replication/index.ts new file mode 100644 index 0000000..68f064b --- /dev/null +++ b/plugins/replication/index.ts @@ -0,0 +1,20 @@ +import { Plugin } from '../../src/index' +import { CronPlugin } from '../cron' + +export class ReplicationPlugin implements Plugin { + constructor(private cronPlugin: CronPlugin) {} + + async init() { + this.cronPlugin.addJob('replication', '*/5 * * * *', async () => { + console.log('Running replication task...') + // Logic for syncing external data to internal database + try { + const response = await fetch('https://api.example.com/data') + const data = await response.json() + console.log('Data fetched for replication:', data) + } catch (error) { + console.error('Replication failed:', error) + } + }) + } +} From 4c519381a56291d1ae34ba7c3eb2ad52d95275f3 Mon Sep 17 00:00:00 2001 From: atecnoco-arch Date: Fri, 17 Apr 2026 14:53:18 +0300 Subject: [PATCH 2/3] Create README.md --- plugins/replication/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 plugins/replication/README.md diff --git a/plugins/replication/README.md b/plugins/replication/README.md new file mode 100644 index 0000000..3beb774 --- /dev/null +++ b/plugins/replication/README.md @@ -0,0 +1,13 @@ +# Replication Plugin + +Syncs data from an external source to the StarbaseDB instance at regular intervals. + +## Configuration + +Enable it in `src/index.ts` by creating a new instance of `ReplicationPlugin`. + +```typescript +new ReplicationPlugin(cronPlugin) +``` + +It uses the `CronPlugin` to schedule the sync task. From d095d9dc9741610a0d27bc629e8d3063082ef236 Mon Sep 17 00:00:00 2001 From: atecnoco-arch Date: Fri, 17 Apr 2026 14:57:17 +0300 Subject: [PATCH 3/3] Update index.ts --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4d08932..21719aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,7 @@ import { QueryLogPlugin } from '../plugins/query-log' import { StatsPlugin } from '../plugins/stats' import { CronPlugin } from '../plugins/cron' import { InterfacePlugin } from '../plugins/interface' - +import { ReplicationPlugin } from '../plugins/replication' export { StarbaseDBDurableObject } from './do' const DURABLE_OBJECT_ID = 'sql-durable-object' @@ -212,7 +212,7 @@ export default { const interfacePlugin = new InterfacePlugin() const plugins = [ - webSocketPlugin, + webSocketPlugin,new ReplicationPlugin(cronPlugin), new StudioPlugin({ username: env.STUDIO_USER, password: env.STUDIO_PASS,