Skip to content

Commit

Permalink
Fix PLC server usage in dev-env (bluesky-social#228)
Browse files Browse the repository at this point in the history
Fix PLC server usage in dev-env, ensure better-sqlite3 bindings are external
  • Loading branch information
devinivy authored Oct 10, 2022
1 parent af5daac commit ef69a72
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/dev-env/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require('esbuild')
'../plc/node_modules/@mapbox/node-pre-gyp/*',
'../server/node_modules/sqlite3/*',
'../../node_modules/classic-level/*',
'../../node_modules/better-sqlite3/*',
],
plugins: [
copy({
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-env/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class DevEnvServer {
break
}
case ServerType.DidPlaceholder: {
const db = await plc.Database.memory()
const db = await plc.Database.memory().createTables()
this.inst = await onServerReady(plc.server(db, this.port))
break
}
Expand Down
3 changes: 2 additions & 1 deletion packages/plc/src/server/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Database {
await this.db.destroy()
}

async createTables(): Promise<void> {
async createTables(): Promise<this> {
await this.db.schema
.createTable('operations')
.addColumn('did', 'varchar', (col) => col.notNull())
Expand All @@ -48,6 +48,7 @@ export class Database {
.addColumn('createdAt', 'varchar', (col) => col.notNull())
.addPrimaryKeyConstraint('primary_key', ['did', 'cid'])
.execute()
return this
}

async dropTables(): Promise<void> {
Expand Down
3 changes: 1 addition & 2 deletions packages/server/tests/_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export const runTestServer = async (
// run plc server
const plcPort = await getPort()
const plcUrl = `http://localhost:${plcPort}`
const plcDb = plc.Database.memory()
await plcDb.createTables()
const plcDb = await plc.Database.memory().createTables()
const plcServer = plc.server(plcDb, plcPort)

// setup server did
Expand Down

0 comments on commit ef69a72

Please sign in to comment.