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

identity-services

v1.0.9

Published

A package for some general-purpose services

Downloads

12

Readme

Identity Admin Services

A package for some general-purpose services

How to install

npm i identity-services

Features

  1. Easy and configurable way for caching any endpoint responses

1. Caching Service

Usage

  • Use the notation @cached above any endpoint you need the response to be cached

Example

// Just add the notation above the HTTP method
@cached()
@httpGet("/")
 public async index(@request() req: IRequest, @response() res: Response) {
  /*
  .. The endpoint body will be executed only when the data is not found in the cache
  */
  return ResponseUtils.send(res, 200, "OK", data);
 }

Add this at the top of your file

import { cached } from "identity-services/lib/cache/decorator";

cached = function (duration, async (cachedData, req) => modified cachedData)

@cached() can be passed 2 optional parameters.

1. duration (number): The validation period of the cached data in milliseconds.

  • After the given period is over, the cached data is cleared for this endpoint and the data will be fetched for the first upcoming request. Hence, it will be cached again.
  • The data will be cached forever if you pass nothing or undefined.

2. async (cachedData, req) => modified cachedData: An optional function that gives you the ability to change any value in the cached data before returning it to the user.

  • The function passes the cached data along with the request as parameters. The function should return the data to be sent to the user.
  • Real example: If you are developing an e-commerce app, and the home page is some products that are the same for all the users, except that each user has his favorite products. So the cached data is the same, but you need to alter some values in it. This can save much time instead of re-fetching the whole data from scratch.
@cached(undefined, async (cachedData, req) => {
 // Apply any updates here on the cached data.
 // It should return the data to be sent to the user.
return cachedData;
})

Cache reset

You don't have to wait for the validation period to reset a cache entry. You can delete a cache entry manually after some action is happened.

  • Real example: If you have an endpoint with /v1/videos path that fetch some videos. You cached the data forever without passing any value for the duration and you only need to clear this cache entry and fetch the data again from the database when creating any new video or updating an existing one.

VideoController.ts

@controller("/v1/videos", isAuth, defaultHeaders)
export default class VideoController extends BaseController {
 /* ..
 ..
 */

 @cached()
 @httpGet("/")
 public async index(@request() req: IRequest, @response() res: Response) {
  /*
   .. The endpoint body will be executed only when the data is not found in the cache
   */
 }
}
  • You can delete the cache entry in the resource file of this model in the after handler of the create and edit, or any customized place that makes any change in the data.

videoResource.ts


import VideoController from "@pbb/api/v1/controllers/VideoController"; 

import { deleteAllCacheEntriesByPathName } from "identity-services/lib/cache/deletionMethods";
import { CacheHelper } from "identity-services/lib/cache/pathHelper";


// Returns the path of the controller, for the above example, will return '/v1/videos'
// You can put that as a static value for example path = '/v1/videos', but it is more dynamic this way
const path = CacheHelper.getControllerPath(VideoController);

const VideoResource: IResourceFile = {
 properties: {
  /*
  ..
  */
  crudOperations: {
   create: {
    async after(req, document, currentUser, params) {
     deleteAllCacheEntriesByPathName(path); // deletes the cached data for any endpoint in the video controller
     return document;
    },
   },
   update: {
    async after(req, document, params, currentUser) {
     deleteAllCacheEntriesByPathName(path);
     return document;
    },
   },
  },
 },
};

export default VideoResource;

deleteAllCacheEntriesByPathName: Passed the path of the controller as an argument, and it deletes the cache entries for any cache entry that has the prefix /v1/videos

2. Dump Service

Usage

  • Use the DumpService initialization function before initializing the wildcard * route.
  • This will provide two routes:
    • POST /identity/services/dump: Accepts a list of models to exclude from the dump operation.
    • GET /identity/services/models: Retrieves a list of model names from the source database.
  • For Dump Service configurations See the documentation
  • For usage on identity dashboard you can use DumpServiceAction from identity-admin-ui Example
    DumpService({
        expressApplication: Application;
        awsRegion: string;
        awsAccessKeyId: string;
        awsAccessSecretKey: string;
        sourceSecurityGroupId: string;
        destinationSecurityGroupId: string;
        sourceIpRanges: string;
        sourceDBUrl: string;
        destinationDBUri: string;
        sourceDbName: string;
        authMiddleWare?: (req: Request, res: Response, next: NextFunction) => Promise<void>;
    });