marebol-db

1.0.0 • Public • Published

MarebolDB

An Express wrapper that lets you connect to the Replit database through the browser using WebSocket. (Only works on REPLs)

Usage

Server:

var MarebolDB = require("marebol-db");
var app = MarebolDB.start();
app.get("/", function(req, res) {
    res.write(app.marebol(__dirname + "/index.html"));
    res.end();
})
app.marebolListen(3000, function(id) {
    console.log("Listening on 3000, connect to DB using ID " + id);
});

Client (index.html) (note: <MAREBOL_ID> will be replaced by the program above, do not change this}):

<!DOCTYPE HTML>
<html>
  <head>
    <script src="marebol/marebol.js"></script>
  </head>
  <body>
   <script>
     (async () => {
     var database = new MarebolDB(<MAREBOL_ID>);
     await database.set("Hello", "World!");
     console.log(await database.get("Hello"));
     // World!
     })();
   </script>
  </body>
</html>

Package Sidebar

Install

npm i marebol-db

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

5.75 kB

Total Files

3

Last publish

Collaborators

  • diegab