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

configeek-ic-js

v0.0.6

Published

Configeek Javascript SDK for Internet Computer

Downloads

9

Readme

Configeek-IC-JS

Configeek JavaScript IC SDK for Internet Computer can be installed as an npm package.

Installation

NPM

Install the npm package and embed Configeek JavaScript IC SDK into your project.

npm install configeek-ic-js

Import Configeek JavaScript IC SDK into your code.

import {Configeek} from "configeek-ic-js";
//or
const {Configeek} = require("configeek-ic-js")

Usage

Initialization

Configeek JavaScript IC SDK must be initialized in order to use any method available. The only exception is Configeek.isInitialized getter which can be used to check if SDK is initialized.

Project API key is needed to initialise Configeek JavaScript IC SDK.

It can be found in your project settings at https://configeek.app.

const config: InitConfig = {
    apiKey: "<API_KEY>",
}
Configeek.init(config)

InitConfig has the following interface:

export type InitConfig = {
    /**
     * Project API key
     */
    apiKey: string,
    /**
     * Whether to fetch the configuration periodically. `false` by default
     */
    periodicFetchingEnabled?: boolean
    /**
     * Callback that notifies about updated keys in configuration
     * @param {{ updatedKeys: Array<string> }} result
     */
    onConfigurationUpdatedCallback?: (result: { updatedKeys: Array<string> }) => void
    /**
     * Periodic fetch interval. `300000` by default (5 minutes in milliseconds). One minute minimal.
     */
    fetchIntervalMillis?: number
    /**
     * Actor configuration. Used when Configeek library is used in a project running on local replica.
     */
    localReplicaConfig?: ReplicaConfig
}

Working with configuration

All configuration related data stored in browser's localStorage

Get all configuration

This method returns the configuration or undefined if configuration is not yet initialized.

const allConfiguration: Record<string, string> | undefined = Configeek.getAll()

Get value of a key

This method returns the value of the configuration key or undefined if there is no such key or configuration is not yet initialized/loaded or can't be loaded.

const myKeyValue: string | undefined = Configeek.getValue("myKey")

Periodical fetching

Periodical fetching can be used to monitor configuration changes automatically without manual fetch.

periodical fetching status
const enabled: boolean = Configeek.isPeriodicFetchingEnabled
start periodical fetching
Configeek.startPeriodicFetching()
stop periodical fetching
Configeek.stopPeriodicFetching()

Manual fetching

Configuration can be fetched manually at any time (after initialization)

Configeek.fetchConfig()

Cleanup

Sometimes it is worth to delete all data related to configuration. This method stops periodical fetching and removes all data stored in localStorage.

Configeek.destroy()

Configeek on environments other than IC main network

In order not to mix configuration from development environment with configuration from production environment we suggest separating development (DEV) and production (PROD) environments by creating additional project in Configeek portal.

Initialization in the code would look like this:

const CONFIGEEK_PROJECT_API_KEY_PROD = "ABCD"
const CONFIGEEK_PROJECT_API_KEY_DEV = "EFGH"

if (process.env.NODE_ENV === "development") {
    Configeek.init({apiKey: CONFIGEEK_PROJECT_API_KEY_DEV})
} else {
    Configeek.init({apiKey: CONFIGEEK_PROJECT_API_KEY_PROD})
}