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

rmsqldb

v0.1.4

Published

Code to connect to and communicate with SQL Server for legacy RM databases

Readme

rmsqldb

Provides express middleware and JS decorator functions allowing easy management of connections to the legacy RM databases. It also provides a mapping of legacy databases in order to connect to a legacy database using an routematch provided agency name.

Agency Header

In order to access a legacy database, the API call must include the header x-rm-agency-name which should match the name of the legacy database (which also matches the name of the agency). For instance a request intended for GRTA would include x-rm-agency-name: RM_GA_GRTA as a request header.

Authorization

To authorize that the requestor has access to the provided agency, the request must also include user data decrypted from a JWT bearer token. This data will include a set of scopes (permissions) that the requestor is allowed to access. If the scope includes access to the agency database listed in the header, the request is allowed. Otherwise, a 403 Forbidden response will be given.

Usage

rmsqldb provides both express middleware and javascript decorator functions for managing access to the legacy RM databases.

Consumption and Authorization of the x-rm-agency-name Header

The AgencyResolver middleware is provided to retrieve and authorize the agency name stored in the header of a request. Athorization requires that a JWT bearer token has already been decrypted on the request using the express-jwt middleware (as suggested by auth0). If no information from the token is found, an exception will be thrown.

import { AgencyAuthorizer } from "rmsqldb";

const app = express();
app.use(AgencyAuthorizer);
...
app.get("/", (req, res) => {
    const agency = req.agency;
});

As you can see, the middleware will attach the agency name to the request object where it can be used by any code that is processing the request.

Legacy Database Connections

The ConnectAgency middleware is provided to simplify access to the the legacy database for the agency specified. It requires the request to have first been processed by the AgencyAuthorizer middleware. Usage of the middleware will attach a connected db object to the request that wraps calls to the mssql library and can be used to communicate directly with the agency's database.

import { ConnectAgency } from "rmsqldb";

const router = express.Router();
router.get("/:id", ConnentAgency, (req, res) => {
    req.db.query("SELECT * FROM tblUser")
        .then(...)
        .catch(...);
});

See this document for more information about the usage of the db object.

A decorator function (RMDBConnect) is also provided for the purpose of providing a connection to the agencies database. This is intended for use on a controller function as opposed to on a route path. The two are interchangeable (depending on your preference) with the exception that the middleware can be applied to a base path (in which case it would apply to all downstream paths as well).

router.ts

import { UserController } from "./controllers"

export const router = express.Router();
router.get("/:id", UserController.GetUserById);

controllers.ts

import { RMDBConnect } from "rmsqldb";

export class UserController {
    @RMDBConnect
    GetUserById(req, res) {
        // EXAMPLE ONLY: SQL injection vulnerability!!
        req.db.query(`SELECT * FROM tblUser WHERE ID = ${request.params.id}`)
            .then(...)
            .catch(...);
    }
}