Giter Site home page Giter Site logo

barishnamazov / madata Goto Github PK

View Code? Open in Web Editor NEW

This project forked from madatajs/madata

0.0 1.0 0.0 422 KB

Make any cloud service with an API your backend! WIP

Home Page: https://madata.dev

License: MIT License

JavaScript 91.32% CSS 6.63% Nunjucks 2.05%

madata's Introduction

Logo showing a cloud presented as a tree

Madata

Make any cloud service with an API your backend! A spinoff from Mavo.

Here be dragons Madata has not yet been officially released, we are trying a “soft launch” first. It is currently in pre-alpha and very much a work in progress. Please try it out, and open issues as you find them!

Getting Started

Madata provides a unified API for authentication, reading & storing data, as well as file uploads (where supported), regardless of the storage service used. You don’t need to worry about differences between the different APIs, and swapping one storage service for another is as easy as changing a URL! Each supported backend documents what kinds of URLs it supports. Then Backend.create(url) automatically gets you an instance of the corresponding backend.

import Backend from "https://madata.dev/src/index.js";

let backend = Backend.create("https://github.com/leaverou/repo/data.json");
let json = await backend.load();

json.happy = true;

await backend.store();

console.log("Stored some data!");

Supported backends

Service Auth? Writes? Uploads?
GitHub Files
GitHub Gist
GitHub API
Dropbox
Google Drive
Google Firebase
Google Sheets
Google Calendar
Local storage
HTML Element
Basic remote fetching

Authentication

Show auth status to the user:

backend.addEventListener("mv-login", evt => {
	header.classList.add("logged-in");

	let user = backend.user;
	my_username.textContent = user.username;
	my_avatar.src = user.avatar;
});

backend.addEventListener("mv-logout", evt => {
	header.classList.remove("logged-in");
});

To have buttons for login/logout:

loginButton.addEventListener("click", evt => backend.login());
logoutButton.addEventListener("click", evt => backend.logout());

Read more about authentication

Storage

Save:

let fileInfo = await backend.store(json);

Uploads

For backends that support uploads, this is how simple it could be to create an image uploader:

<input type=file id=uploader>
uploadForm.addEventListener("submit", evt => {
	evt.preventDefault();

	let file = uploader.files[0];

	if (file && file.type.startsWith("image/")) {
		backend.upload(file, `images/${file.name}`);
	}
});

You can check if backend.upload is defined to see if the backend supports image uploads.

madata's People

Contributors

dmitrysharabin avatar leaverou avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.