Skip to content

feat: Allow starbase to be published#60

Merged
Ehesp merged 4 commits intoouterbase:mainfrom
Ehesp:publish
Jan 13, 2025
Merged

feat: Allow starbase to be published#60
Ehesp merged 4 commits intoouterbase:mainfrom
Ehesp:publish

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 @outerbase/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',
	},
});

...

@Ehesp Ehesp merged commit da9b1da into outerbase:main Jan 13, 2025
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