1.0.1 • Published 4 years ago

sonde v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

A functional approach for API integration.

Usage Backend

const sonde = require("sonde");

sonde.hello = () => {
  return {
    message: "world";
  };
};

sonde.greetings = (name) => {
    return `Greetings ${name}. This is from Sonde or in english, Probe.`
}

// With Express Framework, but feel free to use anything you want.

// Express Setup here. BodyParser is required to parse the body into JSON.

app.get("/sondeapi", (req, res) => {
  res.json(sonde(req.body.name, ...req.body.args));
  // req.body.name : name of the "function" called.
  // req.body.args : arguments of the "function" called.
});

Usage Frontend

<!-- in the head -->
<script src="https://cdn.jsdelivr.net/gh/STR1Z/sonde/frontend/sonde.js"></script>

<!-- fetching from the backend -->
<h1 sonde="hello">{{hello.message}}</h1>
<!-- "hello" is the "function" name. -->
// in javascript code...
sonde("greetings", "George").then((res) => console.log(res));
// Hooray for Promises
1.0.1

4 years ago

1.0.0

4 years ago

0.0.1

9 years ago