-
-
Save raucao/c2d3c4d95fbd9bc138df13010b891a32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"node-fetch": "^2.6.9", | |
"remotestoragejs": "2.0.0-beta.6" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('============================================='); | |
global.fetch = require('node-fetch'); | |
const RemoteStorage = require('remotestoragejs'); | |
const mod = { | |
async alfa () { | |
var Bookmarks = { name: 'bookmarks', builder: function(privateClient, publicClient) { | |
return { | |
exports: { | |
addBookmark: function(bookmark) { | |
return privateClient.storeFile('application/json', bookmark.id, bookmark); | |
} | |
} | |
} | |
}}; | |
const remoteStorage = new RemoteStorage({ | |
modules: [ Bookmarks ], | |
logging: true | |
}); | |
'ready,not-connected,connected,disconnected,error,features-loaded,connecting,authing,wire-busy,wire-done,sync-req-done,sync-done,network-offline,network-online,sync-interval-change'.split(',').forEach(function (e) { | |
remoteStorage.on(e, function() { | |
console.log('did emit ' + e); | |
}); | |
}); | |
remoteStorage.access.claim('bookmarks', 'rw'); | |
remoteStorage.caching.enable('/'); | |
remoteStorage.on('ready', async () => { | |
await remoteStorage.bookmarks.addBookmark({ | |
id: 'alfa', | |
url: 'http://unhosted.org', | |
description: 'Unhosted Adventures', | |
tags: ['unhosted', 'remotestorage', 'no-backend'] | |
}).then(res => { | |
console.log('did write', res); | |
}); | |
const bookmarks = await remoteStorage.scope('/bookmarks/').getAll(''); | |
console.log(bookmarks); | |
}) | |
} | |
}; | |
mod.alfa(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment