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

@colucom/osseus-server

v1.0.6

Published

Osseus server

Downloads

60

Readme

JavaScript Style Guide

Osseus Server

express based osseus web server module

Install

$ npm install @colucom/osseus-server

Usage with MOLECULER-WEB AS MIDDELWARE

Configuration

Mandatory:

To use the moleculer-web api gateway module as a middleware of the express, this configuration are mandatory.

  • OSSEUS_MOLECULERWEB_LOAD: false

    • the init of the osseus module will be preformed as part of this module code and not in the init of the osseus it self.
  • OSSEUS_SERVER_SHOULD_USE_MOLECULER_WEB_AS_MIDDLEWARE: true

    • this flag indicates to the module to use the moleculer-web osseus module.
Optional:

Logging

To use custom logging as a middleware of the express, it's necessary to config this 2 configurations.

  • OSSEUS_SERVER_SHOULD_USE_CUSTOM_LOGGING_METHOD: true

  • OSSEUS_SERVER_CUSTOM_LOGGING_METHOD_PATH: 'Custom Path'

    • the custom path of the logging middelware method in the original project that uses the osseus-server.

Custom middlewares

To use custom middelwares you should provide path to array of middleware functions.

  • OSSEUS_SERVER_MIDDLEWARES_PATH: 'Custom Path'

    • the custom path of the array of middelware functions in the original project that uses the osseus-server.

Errors Map json

To use custom errors map json you should provide path to this json.

  • OSSEUS_SERVER_ERRORS_MAP_PATH: 'Custom Path'

Handle 404 Errors - Redirect the request to another server

If you wish to redirect the request to another server when 404 not found error occures you should provide base url of this server.

  • REDIRECT_BASE_URL: 'Custom URL'

Usage

Configuration

Mandatory:

  • OSSEUS_SERVER_PORT

Optional:

  • OSSEUS_SERVER_REQUEST_ID_HEADER
  • OSSEUS_SERVER_MAINTENANCE_ENABLED
    • set to true to enable maintenance mode on server
  • OSSEUS_SERVER_MAINTENANCE_MESSAGE
    • maintenance message sent to clients when maintenance mode is enabled
  • OSSEUS_SERVER_MAINTENANCE_OVERRIDE_HEADER
    • bypass maintenance mode with this header
  • OSSEUS_SERVER_ALLOWED_IP
    • list of ip addresses allowed to bypass maintenance mode
  • OSSEUS_SERVER_COMPRESION_ENABLED
  • OSSEUS_SERVER_COMPRESSION_LEVEL
  • OSSEUS_SERVER_NO_COMPRESSION_HEADER
    • don't compress responses with this request header
  • OSSEUS_SERVER_MORGAN_FORMAT
  • OSSEUS_SERVER_CORS_WHITELIST
  • OSSEUS_SERVER_STATIC_ENGINE_TYPE
  • OSSEUS_SERVER_VIEWS_FOLDER
  • OSSEUS_SERVER_STATIC_FOLDER
  • OSSEUS_SERVER_ADD_HEALTHCHECK
    • add /healthcheck endpoint which returns OK with status code 200
  • OSSEUS_SERVER_ADD_IS_RUNNING
    • add /is_running endpoint which returns OK with status code 200

Example

First, create index.js:

const Osseus = require('osseus')

const main = async () => {
	try {
		// init osseus
		const osseus = await Osseus.init()
  	} catch (err) {
		console.error(err)
  	}
}

main()

Running:

$ node index.js --OSSEUS_SERVER_PORT 8080

Will result in:

server is listening on port: 8080

Contributing

Please see contributing guidelines.

License

Code released under the MIT License.