npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rest-service-integration

v1.0.4

Published

Allows to Integrate your server hitpoints to another server very easily.

Downloads

4

Readme

Rest Service Integration

Allows to Integrate your server hitpoints to another server very easily.

Installation

npm install rest-service-integration

Usage

Server1

This is the main server. It will use Server2's API to send the data back to client

...
const RestIntegration = require("../");

const server2 = new RestIntegration.Service({
    host: SERVER2_HOST
})

app.get("/", async (req, res) => {
    res.send((await server2.hello()).data)
})


app.listen(SERVER1_PORT, async () => {
    await server2.load()
    console.log("Server1 Started...")
})
  • Here when express app is ready it will load the API model from Server2 using POST /rest-service-integration-mode hitpoint.

  • When it loads the data, hello Function will be avilable to server2 Instance.

Server2

This server is the one which will be loaded by Server1.

...

app.get("/hello", (req, res) => {
    res.send("Hello!");
})


app.post("/rest-service-integration-model", (req, res) => {
    const model = {
        "hello": {
            name: "hello",
            url: "/hello",
            method: ["GET"]
        }
    }

    res.json(model)
})

app.listen(SERVER2_PORT, () => {
    console.log("Server2 Started...")
})
  • Here /rest-service-integration-model will be requested when you use await server2.load() in Server1.

  • Service Instance will try to make a tree structure of the API model and attach those functions and Objects to the instance it self.

After using await server2.load()

  • When you call it; instance will reach to POST /rest-service-integration-mode hitpoint and will try to load the API model.

  • When it gets the model it will try to struct that model and attach the functino to instance.

  • If model element has a key named "hello", it will name that function to "hello".

  • If that model element has more then one method it will attach that function like this

server2.hello.get();
server2.hello.post();

THIS PACKAGE IS NOT FULLY TESTED YET. IT MIGHT HAVE SOME BUGS, IF YOU FIND ANY BUGS PLEASE REPORT IT IN ISSUES SECTION OF THIS REPOSITORY. I DONT RECOMMAND USING IT FOR BIG PROJECTS AS IT IS NOT FULLY TESTED AS A WELL MADE PACKAGE. SO USE IT AT YOUR OWN RISK.


Coded by Henil Malaviya with :heart: