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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@milkandcartoons/service-communication

v0.2.20

Published

Package for service communication between node apps with MongoDB

Readme

Initializing

Client:

// file endpoints.js
import { SCClient } from '@milkandcartoons/service-communication';

const endpoints = [{
  name:  'core',
  url:  process.env.CORE_ENDPOINT_URL,
}];

const scClient =  new SCClient(endpoints);  

export default scClient;

Import scClient to context creation

// file index.js
import scClient from  './endpoints';

// Context creation method
...
// Init client
context.endpoints = scClient.init(context);
// Or add optional contextMapper for mapping context for each request
context.endpoints = scClient.init(context, ctx  => ({ user: ctx.user }));
...

Server:

import { SCServer } from  '@milkandcartoons/service-communication';

const scServer = new SCServer({});

export default scServer;

// sc query schema
export const scSchema =  `
  type Query {
    ${scServer.query}
  }
  ${scServer.type}
`;

// sc query resolvers
export const scResolvers = {
  Query: scServer.resolvers,
};

For graphql-import

//schema.graphql

#import ${pathToNodeModules}/@milkandcartoons/service-communication/src/SCServer/scSchema.graphql

For nexus-prisma

  scServer.prismaTypes - is a necessarry prisma types, you should pass it to the schema creation function.

  scServer.prismaQuery - is the sc query for 'query' and 'function', call it in query definitions function with 't' like this 'scServer.prismaQuery(t)'

For GraphQL requests - SCServer is not required, but you should parse received context from headers and merged with your graphql context. In each request, field context is received in headers in JSON format. Context mapper on client allows you transform context, which will be received on the server request headers

const additionalContext = JSON.stringify(req.headers.context)

GraphQL request example:

context.endpoints.core.sc.graphql({
  query: 'orders',
  $args: { _id: '1234' },
  $fields: {
    _id: 1,
    name: 1,
    $fragments: {
      DeliveryOrder: {
        items: {
          _id
        }
      }
    }
  }
})

GraphQL request syntax

Request with all syntax features

  sc.graphql({
    mutation: 'mutationName',
    $args: {
      argOne: 'Hello',
      argTwo: ['Hello', 'World'],
      nestingArg: {
        arg: 'World'
      }
      enumsArrayArg: {
        $enum: ['ONE', 'TWO']
      },
      enumArg: {
        $enum: 'HELLO'
      }
    },
    $fields: {
      _id: 1,
      $fragments: {
        ImplementingType: {
          name: 1,
          uniqueFieldForThisType: {
            awesomeField: 1
          }
        }
      },
      fieldWithArgs: {
        $args: {
          _id: '123213'
        },
        $fields: {
          fieldValue: 1
        }
      }
    }
  })

Arguments

Arguments is $args key in definition option in .graphql method.

Standart using

  {
  ...
  $args: {
    _id: 'value',
    nested: {
      key: 'value'
    },
    array: ['One', 'Two'],
    numberArray: [1, 2, 3],
    boolean: true
  }
  ...
  }

Using with enums

{
  ...
  $args: {
    singleEnum: {
      $enum: 'HELLO'
    },
    arrayOfEnums: {
      $enum: ['CHO', 'BAR']
    }
  }
  ...
}

Fields

Standart using

  {
    ...
    $fields: {
      _id: 1,
      nested: {
        key: 'value'
      }
    }
    ...
  }

Using with fragments

{
  ...
  $fields: {
    _id: 1,
    $fragments: {
      TargetTypeName: {
        field1: 'value'
      }
    }
  }
  ...
}