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

ndx-server

v0.18.1

Published

my server framework

Downloads

113

Readme

ndx-server

A lightweight, robust, modular server built on Express and Alasql

Features

  • No need for a database server
  • Persists to S3 with as few reads and writes as possible
  • Sessionless tokens can withstand a server restart
  • Scale servers easily using ndx-sync
  • Schemaless SQL database which treats javascript objects as first class citizens

npm install --save ndx-server

var ndx = require('ndx-server');

Example

  var ndx = require('ndx-server')
  .config({
    database: 'rb',
    tables: ['users', 'tasks'],
    port: 23000
  })
  .controller(function(ndx) {
    ndx.app.get('/api/thing', function(req, res) {
      res.json({
        hey: 'yo'
      });
    });
  })
  .start();

Methods

ndx.config(object args) -> ndx

Configure the server

ndx.controller(function controller) -> ndx

Register a controller

ndx.controller(function(ndx) {
  //use the ndx controller
  //register some routes etc
});
ndx.controller(require('./controllers/my-controller'));
ndx.controller('npm-module');

ndx.use(function controller) -> ndx

Register a service

ndx.use(function(ndx) {
  //use the ndx service
  //register some routes etc
});
ndx.use(require('./services/my-service'));
ndx.use('npm-module');

all modules from the folders /startup, /services and /controllers now get auto-loaded so you no longer need to reference them

ndx.start()

Start the server

the ndx object

The ndx object gets passed to each controller and service

Properties

  • ndx.app - The express app
  • ndx.server - The express server
  • ndx.database - The database
  • ndx.settings - Server settings
  • ndx.host - Server host
  • ndx.port - Server port

Methods

  • ndx.generateHash(string) -> hashed string
  • ndx.validPassword(password, hashedPassword) -> bool
  • ndx.authenticate() middleware to authenticate a route, see ndx-user-roles for a more robust implementation
  • ndx.postAuthenticate(req, res, next) used internally
  • ndx.generateToken(string userId, string ip) -> new user token
  • ndx.setAuthCookie(req, res) used internally

other modules can add extra properties and methods to the ndx object, eg ndx-passport which adds ndx.passport for the other passport modules to use.

all ndx modules get auto-loaded by default, so all you need to do is npm install them

modules

ndx-framework

Use the ndx-framework app to quickly create, connect to and configure ndx-server apps