Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow starbase to be published #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ehesp
Copy link
Collaborator

@Ehesp Ehesp commented Jan 9, 2025

Purpose

This PR allows starbasedb to be published to NPM and used in standalone apps. I've verified this works when locally linked.

Some docs need adding on how to do this, but the general flow is:

  1. Install
npm i --save starbasedb
  1. Setup (wrangler.toml)
[[durable_objects.bindings]]
name = "STARBASEDB"
class_name = "StarbaseDBDurableObject"

[[migrations]]
tag = "v1"
new_sqlite_classes = ["StarbaseDBDurableObject"]
  1. Export

In your index.ts file:

export { StarbaseDBDurableObject } from 'starbasedb';
  1. Use / import
import { StarbaseDB } from 'starbasedb';

...


const stubId = env.STARBASEDB.idFromName('TEST');
const stub = env.STARBASEDB.get(stubId);

const rpc = await stub.init()

const starbase = new StarbaseDB({
	dataSource: {
		rpc,
		source: 'internal',
	},
	config: {
		role: 'admin',
	},
});

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants