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

@node-modz/lib-core

v1.0.1

Published

Core Library to initialize any Node API Server

Downloads

3

Readme

lib-core

How to use this package:

Step 1: Install Package

$ npm install @node-modz/lib-core

Step 2: Initializing Server

import Server from '@node-modz/lib-core'

Server().catch((e) => {
    console.error("ledgers-api error:", e);
});

Step 3: Create Authentication to APIs

import {Authorizer,  HttpConfigOptions} from '@node-modz/lib-core'

Add authorizer key as below to app_configuration.

http: {
    cors_allow_domains: process.env.HTTP_CORS_ALLOW_DOMAINS?.split(",") as string[],
    authorizer: Authorizer({url: "http://192.168.0.5:4000/oauth2/verify"})
} as HttpConfigOptions,

Use as middleware for API's that need to be authenticated

import {Container, HttpConfigOptions} from '@node-modz/lib-core'
  
const httpConfigOptions:HttpConfigOptions = Container.get('HttpConfigOptions');

app.use(httpConfigOptions.authorizer)

Step 4: Defining App config

Sample /src/app-config.ts

export const __prod__ = process.env.NODE_ENV === 'production'
export const __SERVER_CONFIG__ = {
    config : [
        {
            prop:'sample',   // Name of the Property key that need to be used from container (Depency injection)
            container_ref:'SampleConfigOptions'// Container identifier
        },
        

    ],
    setup: [
        { init: "Sample Package" } //name of packages to be imported
    ],
    sample: {
        key1: "value 1",
    } as SampleConfigOptions // Configurations that need to be stored 

}

Step 5: Running Server

npm install && tsc
node dist/server.js --init dist/api-config.js
    

Step 6: Overwriting Default configuration

import {ServerConfigOptions,
    HttpConfigOptions,
    Authorizer} from "@node-modz/lib-core";



export const __prod__ = process.env.NODE_ENV === 'production'
export const __SERVER_CONFIG__ = {
    config : [
    
        {prop:'http',   container_ref:'HttpConfigOptions'},
        {prop:'server', container_ref:'ServerConfigOptions'},

    ],
    server: {
        host: "http://localhost:5000",
        port: 5000,
    } as ServerConfigOptions,
    http: {
        cors_allow_domains: process.env.HTTP_CORS_ALLOW_DOMAINS?.split(",") as string[],
        authorizer: Authorizer({url: "http://192.168.0.5:4000/oauth2/verify"})
    } as HttpConfigOptions



}