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

isnode-mod-services

v0.1.9

Published

ISNode Services Module

Downloads

2

Readme

ISNode Services Module

Introduction

This is just a module for the ISNode Framework. To learn how to use the framework, we strongly suggest obtaining a copy of the Hello World example.

The Services module is responsible for loading all installed services and their respective controllers, and for providing an interface for the router to direct requests to the relevent controller.

Configuration

There is currently one attribute that is configurable within the application server's configuration file (config.json) - "allowShutdownFromControllers". If this is set to "true", then it makes the application server (system-wide) shutdown() method available from the "isnode" object that is passed to all of the controllers. If it is set to "false" then the controllers will not be able to access the shutdown() method and will not have any ability to terminate the application server (barring an exception).

  "services": {
    "allowShutdownFromControllers": false
  }

Methods

search(searchObj)

Synchronous Function. Searches for an returns a controller based on serviec name(s), hostname and url (path)

Input Parameters:

  1. searchObj - (Object) Search Object. See example below

Returns: Returns a route object that includes the controller

SearchObj example

 {
   services: ["service1", "service2"],
   hostname: "localhost",
   url: "/web/users/1"
 }

service(name)

Synchronous Function. Returns a service object, given a service name. Using this object you can navigate the service routes (including controllers), database models instantiated against the service and service configuration.

Input Parameters:

  1. name - (String) Name of the service to return.

Returns: Returns a service object

Example

 var helloWorldService = isnode.module("services").service("hello-world");

service(name).cfg()

Synchronous Function. Fetches service configuration object

Input Parameters:

  1. name - (String) Name of the service

Returns: Service configuration object

Example

 var serviceConfig = isnode.module("services").service("hello-world").cfg();

service(name).model.add(modelName, modelObj)

Synchronous Function. Adds a model against a service.

Input Parameters:

  1. name - (String) Name of the service
  2. modelName - (String) Name of the model to add
  3. modelObj - (Object) The model object to add

Returns: Returns true on successful addition of model to service

Example

 // Assume "model" has already been defined
 isnode.module("services").service("hello-world").model.add("test", model);

service(name).model.get(modelName)

Synchronous Function. Fetches a defined model from a service

Input Parameters:

  1. name - (String) Name of the service
  2. modelName - (String) Name of the model to fetch

Returns: Returns the model object

Example

 // Assume "model" has already been defined
 var model = isnode.module("services").service("hello-world").model.get("test");

service(name).url.get(path, options)

Synchronous Function. Takes a controller-relative path and returns application path (including base url)

Input Parameters:

  1. path - (String) Controller-relative path
  2. options - (Object) Child strings of "protocol", "port" and "full". Only need to set protocol and port if full is set as this will return an absolute URL. If full is not set or is set to false it will return the relative path

Returns: Returns a URL (absolute or relative path depending on input)

Example

 // Assume basePath is set to "/test/path"
 var url = isnode.module("services").service("hello-world").url.get("/web/test");
 console.log(url); // Should render "/test/path/web/test"