Skip to content

weisrc/sonde

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A functional approach for API integration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published