beakerbrowser / webdb

The Web is your database.
https://www.npmjs.com/package/@beaker/webdb
MIT License
399 stars 45 forks source link

Replaced node's 'url' module with 'url-parse' to support 'dat://' in node.js #3

Closed AnsonT closed 7 years ago

AnsonT commented 7 years ago

Fixes: https://github.com/beakerbrowser/ingestdb/issues/2

pfrazee commented 7 years ago

Thanks for the PR! Can you give me an example URL that was failing the parse? I want to have a test that reproduces the error.

AnsonT commented 7 years ago
import DatArchive from 'node-dat-archive'
import Injest from 'injestdb'
import tempy from 'tempy'

async function test() {
  const a = await DatArchive.create({localPath: tempy.directory()})
  const dir = tempy.directory()
  const db = new Injest(dir, {DatArchive})
  db.schema({
    version: 1,
    posts: {
      primaryKey: 'id',
      index: ['id'],
      validator: record => (record)
    }
  })
  try {
    await db.open()
    await db.addArchive(a)
    await db.posts.add(a, { id: '1', text: '123' })
    await db.posts.add(a, { id: '2', text: 'abc' })
    const post = await db.posts.get(a, '1')
    console.log(post)
  }
  catch (e)  {
    console.log(e)
  }
}

test()
pfrazee commented 7 years ago

That runs fine to me, and of course I just realized: what version of node are you on? I think the URL API I'm using is a new addition.

pfrazee commented 7 years ago

Yeah the new API is v7+. I'll go ahead and merge, only ~20kb more.

pfrazee commented 7 years ago

Published 2.4.6

AnsonT commented 7 years ago

Sorry, you are right, it’s the node version. I upgraded to 8.6.0 and URL function accepts dat://.

Thanks,

Anson  

From: Paul Frazee notifications@github.com Reply-To: beakerbrowser/ingestdb reply@reply.github.com Date: Thursday, September 28, 2017 at 8:19 AM To: beakerbrowser/ingestdb ingestdb@noreply.github.com Cc: Anson Tsao tsaoa@acm.org, Author author@noreply.github.com Subject: Re: [beakerbrowser/ingestdb] Replaced node's 'url' module with 'url-parse' to support 'dat://' in node.js (#3)

That runs fine to me, and of course I just realized: what version of node are you on? I think the URL API I'm using is a new addition.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.