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

@sumanta23/server-wrapper

v2.0.15

Published

api server wrapping express with best practices"

Downloads

63

Readme

API server

var config = require("config-wrapper");
var redisconnection = require("redisconnection-wrapper")(config.get("redis"));

var mq = require("rabbitmqconnection-wrapper");
mq.start(config.get("rabbitmq"));

var logger = require("applogger-wrapper");
logger.init(config.get("logger"));

var dbMgr = require('mongodbconnection-wrapper');
var dbname = process.env.NODE_ENV === 'test' ? "test" : undefined;
var modelPath= "./db/models";
var schemaPath= "./db/schemas";

var boot = require("boot-wrapper");
var api = require("@sumanta/server-wrapper").api;
var cors = require("cors");
var express = require("express");
var app = express();
app.use(cors("*"));

restPath = __dirname+"/rest";
schemaPath= __dirname+"/schema";
validationRequired= apidocRequired= basicSecRequired = true;
xssIgnoreList=[]
baseURL = "localhost:5000"


boot.init(config)
.then(async ()=>{
    await boot.bootlogger(logger);
    await boot.bootredis(redisconnection)
    await dbMgr.initialize(config.get("db"), { dbname, modelPath, schemaPath })
        .then((mInst)=>boot.bootdb(mInst, dbMgr.getModel()));
    await boot.bootrabbitmq(mq.getConn);
}).then(async ()=>{
    // var Model = appGlobals.dbModels;
    // var vModelName = 'votings';
    // var vDbModels = Model.getModelInstance(vModelName);
    // mq.sendToQueue("test",{"helo":"data"});
    // mq.registerConsumer("test",(data)=>{logger.info(data); return Promise.resolve();});  
    // await vDbModels.create({callId:"55", option:"kl", userId:"ioio"}).tap(()=>vDbModels.findOne({}).tap(console.log))
    api.init(app, 5000, { restPath, schemaPath, validationRequired, apidocRequired, basicSecRequired, xssIgnoreList, baseURL })
    api.loadapi(app);
    api.start(app);
})

Socket server

var _         = require("lodash");
var debug     = require("debug")("wsserver");
var boot = require("boot-wrapper");
var config = require("config-wrapper");
var redisconnection = require("redisconnection-wrapper")(config.get("redis"));
var subchannel = require("redisconnection-wrapper")(config.get("redis"));

var wsconfig = config.get("ws");

var express = require("express");
var http = require("http");
var app = express();
var server = http.createServer(app);

var port = process.env.PORT || wsconfig.port;

boot.init(config)
.then(async () => {
    await boot.bootredis(redisconnection);
    var senderM = require("@sumanta23/server-wrapper").sender;
    await boot.bootsender(senderM);
    //await boot.enableHealthMonitoring("ws");
}).then(async () => {
    var ws = require("@sumanta23/server-wrapper").wsserver;
    ws.listen(server, wsconfig, ()=>{}, redisconnection, subchannel, ()=>{});
    server.listen(port, function () {
    debug("server started on localhost:" + port);
    });
})