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

harno-kernel-server

v0.0.1

Published

Npm module that helps you to build your node js server-like projects

Downloads

3

Readme

Harno-kernel-server

Npm module that helps you to build your node js server-like projects. This module is basically the same as harno-kernel, but it also contains a lot of usefull services for node

Install

npm install harno-kernel-server

Usage

Basic

main.js
// you can export ServerKernel instance
const { YourService } = require('./your.file.js')
const serverKernel = require('harno-kernel-server').default

export default class App {
  constructor () {
    // you can init all default services and it's dependencies
    serverKernel.registerDefaultServices()
    serverKernel.initDefaultServicesDependencies()

    // some services have logger service as their dependencies, so before initing them, it would be great to configure logger
    serverKernel.getService('logger').config({ ... })

    // call init methods of some services
    serverKernel.initDefaultServices()

    // you can register your services like this
    serverKernel.registerService('yourAnyName', YourService)

    // you can init dependencies for your service like this
    serverKernel.initDependencies({
      yourAnyName: ['express', 'config']
    })

    // you can get any service by its name like this
    const yourAnyName = serverKernel.getService('yourAnyName')
    // or
    const yourAnyName = serverKernel.s.yourAnyName
  }
}

Advanced

main.js
// you can export ServerKernel class, or any other available service
const { YourService } = require('./your.file.js')
const { ServerKernel, ConfigService, ExpressService, ... } = require('harno-kernel-server').default

export default class App {
  constructor () {
    this.kernel = new ServerKernel()

    // you can register services
    this.kernel.registerService('express', ExpressService)
    this.kernel.registerService('config', ConfigService)
    this.kernel.registerService('yourAnyName', YourService)

    // you can init dependencies for any service (for some default services you must do that)
    this.kernel.initDependencies({
      yourAnyName: ['express', 'config']
    })

    // you need to call init function of some default services
    this.kernel.s.express.init()

    // in this example YourService would have property _dependencies or _d with links to express and config services
    const yourAnyName = this.kernel.getService('yourAnyName')

    // look at the your.file.js bellow
    console.log(yourAnyName.afterInitDependencies())
    // output: My dependencies is: express and config
  }

  async start () {
    // you can get services like this
    this.kernel.getService('configService').readJson('./path.to.json')

    // or like this
    const port = this.kernel.s.configService.c.port
    await this.kernel.s.expressService.start(port)
  }
}
your.file.js
class YourService {
  afterInitDependencies () {
    // after init your service will have property _dependencies or _d, that will contain all inited dependencies
    const express = this._d.express
    const config = this._d.config

    if (express && config) {
      console.log('My dependencies is: express and config')
    }
  }
}

export { YourService }

API

new ServerKernel()

Creates new server kernel instance

serverKernel.initDependencies(dependenciesConfig)

  • dependenciesConfig example:
  const dependenciesConfig = {
    serviceName1: ['serviceName2', 'serviceName3'],
    serviceName2: ['serviceName4'],
    ...
  }

Inits/sets services dependencies, so that in our example service serviceName1 will have property _dependencies or _d that would contain serviceName2, serviceName3 services

serverKernel.registerService(name, Service)

  • name - service name (can be any string)
  • Service - any js class

Register/saves Service class instance under the name in the server kernel

serverKernel.getService(name)

  • name - service name

Gets service that was created under that name

serverKernel.s

Kernel property that contains all registered services

serverKernel.registerDefaultServices()

Registers all default services under default names (look at Defaut services for more info)

serverKernel.initDefaultServicesDependencies()

Inits all default services dependencies

serverKernel.initDefaultServices()

Inits all default services. Calls init method of default services

Default services

JobsSchedulerService

  • Default name: jobsScheduler
  • Dependencies: ['logger']
  • Description: Class that manages jobs (jobs are functions that behave like cron jobs)
  • API: Work in progress, so more reliable api would be announced later

ExpressService

  • Default name: express
  • Dependencies: ['logger']
  • Description: Class that manages express
  • API: Work in progress, so more reliable api would be announced later

ConfigService

  • Default name: config
  • Dependencies: none
  • Description: Class that manages configuration
  • API: Work in progress, so more reliable api would be announced later

MongoDBService

  • Default name: mongoDB
  • Dependencies: ['logger']
  • Description: Class that manages mongo database with mongoose npm module
  • API: Work in progress, so more reliable api would be announced later

LoggerService

  • Default name: logger
  • Dependencies: none
  • Description: Class that helps with logging
  • API: Work in progress, so more reliable api would be announced later

ErrorHandlerService

  • Default name: errorHandler
  • Dependencies: ['logger']
  • Description: Class that handles different errors
  • API: Work in progress, so more reliable api would be announced later

RequestService

  • Default name: request
  • Dependencies: none
  • Description: Class that does different network requests
  • API: Work in progress, so more reliable api would be announced later

TickService

  • Default name: tick
  • Dependencies: ['logger']
  • Description: Class that manages tick functions (functions that is executed per interval)
  • API: Work in progress, so more reliable api would be announced later

SwaggerService

  • Default name: swagger
  • Dependencies: ['express']
  • Description: Class that manages swagger documentation
  • API: Work in progress, so more reliable api would be announced later

AuthRequestsService

  • Default name: authRequests
  • Dependencies: ['request']
  • Description: Class that helps with authorization routes for (harno-auth mostly at this point)
  • API: Work in progress, so more reliable api would be announced later

ValidationService

  • Default name: validation
  • Dependencies: ['errorHandler']
  • Description: Class that validates different values
  • API: Work in progress, so more reliable api would be announced later

License

License