0.0.7 • Published 5 years ago

dbdbdb v0.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

DBDBDB - Simple JSON File Database Using Dropbox Javascript SDK

Prerequisites

  1. Create an dropbox api App folder app: https://www.dropbox.com/developers
  2. Save the app key

Usage:

Install: npm i dbdbdb --save

import dbdb from "dbdbdb";

const {
  authUrl,
  getClient,
  logOutDropbox,
  readDatabase,
  updateDatabase,
  uploadImage
} = dbdb({ clientId: "YOUR_APP_KEY" });

authUrl String

A url to enable a user to authenticate with Dropbox and redirect to your app with an auth token.

Dropbox SDK Reference: http://dropbox.github.io/dropbox-sdk-js/Dropbox.html#getAuthenticationUrl

Authentication Flow Information: https://www.dropbox.com/developers/reference/oauth-guide

getClient Function

Returns a Dropbox SDK class instance. If a client instance is not yet available, it creates a new one by using a token found in sessionStorage or in the current url.

logOutDropbox Function

Removes authentication token from localStorage. You are responsible for destroying your application's SDK client instance.

readDatabase Function

Returns a Promise. Fetches the configured JSON database file from dropbox, parses the data and returns it.

Usage:

readDatabase().then(({ articles }) => {
  // do something with articles
});

updateDatabase Async Function

Returns a Promise. Reads the current database, then peforms a shallow merge of that with the new data provided in argument.

Usage:

updateDatabase({ data: { articles: [{ title: "My Article" }] } });

uploadImage Async Function

Returns a file object containing a public image url.

Usage:

const image = await uploadImage({ file: { ... } });
console.log(image.url); // https://public-url-to-image

See React example

0.0.7

5 years ago

0.0.6

5 years ago

0.0.55

5 years ago

0.0.5

5 years ago

0.0.45

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago