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 🙏

© 2025 – Pkg Stats / Ryan Hefner

identity-code-api-controllers

v1.0.0

Published

Supplies the controller functions for the Identity Code APIs.

Readme

identity-code-api-controllers

Supplies the controller functions for the Identity Code APIs.

Setup

To initialize your controllers, you must first supply the module with an object of configuration options:

The options are:

  • bucketName - the name of the s3 bucket where the resources and resource logs are stored.
  • storageFile - the name of the file where the resources are stored.
  • logFile - the name of the file where the logs are stored.
  • resourceNameSingular - the singular form of the resource name.
  • resourceNamePlural - the plural form of the resource name.
  • sortNameSingular - (Optional) the singular form of the sort group name (ex: state codes are grouped by country codes).
  • sortNamePlural - (Optional) The plural form of the sort group name.
  • paginate - (Optional) An object that sets the default properties for pagination. Can be a boolean value (true) instead of an object to use all the default values. Any property not specified is set to the default. Below are the properties that can be specified and their defaults:
    • default_start - Defaults to 1.
    • default_size - Defaults to 50.
    • max_page_size - Defaults to 100.

All this will be passed in to the init function and should be placed in the code where the server is initialized.

Setup Example:

Note: sortNameSingular and sortNamePlural are not used in this example.

const controllers = require('identity-code-api-controllers');

controllers.init({
    bucketName: 'identity-level-of-education-dev-bucket-s3',
    storageFile: 'identity-level-of-education-dev-bucket-s3.json',
    logFile: 'logs.json',
    resourceNameSingular: 'level_of_education',
    resourceNamePlural: 'levels_of_education'
});

Verify Controller Initialization

If, for some reason, you want to verify that the controllers have been initialized, call the configured function:

Example:
controllers.configured() // returns true if configured and false if not.

Verify Pagination Initialization

If you want to check that the the server has configured pagination options:

controllers.paginated() // returns true if configured and false if not.

Access Configuration Options

To access these configuration options later in your code, call the controller retrieve functions.

Example:
const config = controllers.retrieve;

// General controller settings
config.bucketName();
config.storageFile();
config.logFile();
config.resourceNameSingular();
config.resourceNamePlural();

// Sort name setting for identity code APIs with two parameters
config.sortNameSingular();
config.sortNamePlural();

// Pagination options (only used in large data identity code APIs)
config.pageDefaultStart();
config.pageDefaultSize();
config.pageMaxSize();

// General link properties
config.resourceNameInfo(); // `${resourceNamePlural}__info`
config.resourceNameCreate(); // `${resourceNamePlural}__create`
config.resourceNameModify(); // `${resourceNamePlural}__modify`
config.resourceNameRemove(); // `${resourceNamePlural}__remove`
config.resourceLogsInfo(); // `${resourceNameSingular}_logs__info`

// Pagination link properties
config.resourcePageFirst(); // `${resourceNamePlural}__first`
config.resourcePageLast(); // `${resourceNamePlural}__last`
config.resourcePagePrev(); // `${resourceNamePlural}__prev`
config.resourcePageNext(); // `${resourceNamePlural}__next`

Define The Controllers

To define the controllers, call the controller functions.

  • getAllResources
  • createResource
  • getResource
  • modifyResource
  • deleteResource
  • getResourceLogs
Example:
exports.getLevelsOfEducation = controllers.getAllResources;
exports.createLevelOfEducation = controllers.createResource;
exports.getLevelOfEducation = controllers.getResource;
exports.modifyLevelOfEducation = controllers.modifyResource;
exports.removeLevelOfEducation = controllers.deleteResource;
exports.getLevelOfEducationLogs = controllers.getResourceLogs;