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

nexi

v3.0.0

Published

Nodejs rails-ish port

Downloads

148

Readme

npm Build Status

Nexi

A rail-ish framework for node.js

There are a lot of node.js frameworks, and even some inspired by ruby on rails, but to my knowledge there is still no framework that brings the same conventions and ease of new application development to node. A saga...

Documentation

Head to the wiki for full documentation.

Features

This is a quick glance at some of the niceties provided by nexi. For a deep dive into all of the bells and whistles, check out the docs

Mvc

Nexi is a mvc web framework that is designed to provide a foundation for building applications that scale cleanly and easily.

Controllers

Nexi controllers are fairly simple, and combined with several other conventions provide a very easy means to adding new pages or api endpoints to your application.

// src/app/controllers/home-controller.js
const { BaseController } = require('nexi')

class HomeController extends BaseController {

  async welcome(req, res) {
    const user = this.context.models.users.findOne({ id: req.params.id })
    return res.render('home/welcome',  { user } )
  }
}
module.exports = WelcomeController

Routing

Modeled after rails routes, the router is simple yet powerful providing one organized space to declare all of your applications routes cleanly. The router hooks into Nexi middleware enabling an easy way to configure per route (or a group of routes) pre/post request handlers. Namespace blocks and inline handlers are also supported.

// src/routes.js
module.exports = (context, router) => {
  router.get('/welcome/:id', 'homeController#welcome')

  router.get('/secret', 'requireLogin', 'secretController#shh')
}

Views

Nexi comes with a templating engine (handlebars hooked up out of the box. For apis, views can be omitted through configuration. Layouts, view helpers, partials, and other common mvc view components are also provided.

// src/app/views/home/welcome.js
<div>
    <h1>Welcome {{user.name}}!</h1>
</div>

Models

Nexi also comes with an orm (waterline) as well as a fully featured migrations tool. These can also be disabled through configuration.

//src/app/models/User.js
module.exports = {
  identity: 'user',
  datastore: 'default',
  attributes: {
    name: {
      type: 'string',
      required: true,
    },
  }
}

Context

Instead of providing Nexi components (such as models or the application configuration) as global variables, Nexi exposes these components through a context (see context design pattern) object injected into and accessible within any Nexi hook (controllers, middleware, decorators, initializers). This provides simple dependency injection pattern that promotes reusability, testability, and maintainability.
You can also decorate context with anything you'd like to be globally available.

//src/decorators/index.js
module.exports = (context) => {
  context.elasticSearchClient = new elasticsearch.Client()
}

...

const results = await this.context.elasticSearchClient.search(params)

But wait, there's more...

  • Middleware - Easy to add global pre/post request middleware along with router middleware make it easy to controller the request flow
    • Built in middleware - Request logging, error responses, global exception handlers, security, compression
  • Built in decorators - models, error reporter, application logger, application configuration
  • Initializers & bootstrap support - handle startup logic in either config/boot.js or group like functionality in initializers
  • Sessions - session store provided out of the box