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

espresso-js

v1.0.20

Published

A Ruby on Rails clone for Node

Downloads

50

Readme

espresso

Why use espresso over Rails?

  • Platform Compatibility
    • has CLI supported by Javascript, not Ruby. This means out-of-the-box compatibility with Windows
  • WebSockets > AJAX
    • has OOTB support for sockets as specific as route-level
    • supported by Socket.IO, meaning compability with older browsers through long polling
  • Asset Specificity > Asset Clashing
    • has decoupled compiled assets for each controller, whereas Rails bundles all your styles and scripts together
  • MongoDB > SQL
    • has OOTB MongoDB support for flexible-schema-lovers
  • Event Loop Request Management > Threaded Request Management
    • using javascript means having the event loop. Throw requests at anything in memory and never worry about those nasty race conditions
  • Node Libraries
    • have access to all your favorite Node libraries in this highly unopinionated framework

Getting started

Conventions

Before we start, it's important to mention a few important conventions that should be followed when using espresso.

Unfortunately, espresso is not perfect. Not following these conventions might result in espresso breaking or being unable to start a server.

Running espresso's command line

When running commands, all commands should be run from the outermost directory of your app directory.

For example, if your project is called HelloWorld. Commands should be run in

/HelloWorld

They should not be run in any of the following or similar directories

/HelloWorld/app
/HelloWorld/config
/GoodbyeWorld

Why?

espresso currently does no checking of which sublevel of your app directory you are in. It needs help determining relative paths.

Using require()

When using require() inside of controllers, please require('path'); and then prepend your require paths with path.resolve(). After prepending, use relative paths from the main app directory, instead of __dirname, ., or other methods that assume your current file's location.

Why?

espresso runs it's own server configurations when starting a server and will interpret controller files in a different directory. Therefore, using __dirname and others will not work as expected.

It should be noted that only controllers are evaluated this way, so require() statements in other places should work as expected.

Creating your first espresso app

Installation

Let's get started! To install espresso, run the following command

npm install espresso-js --global

Creating the app

To create the app, run the following command

espresso new APP_NAME

Afterwards, cd into your app directory and make sure that personal attributes in package.json are to your liking.

And make sure to install app dependencies by running npm install!

Generating a controller

To generate a controller, run the following command espresso generate controller CONTROLLER_NAME [ACTION:METHOD]

Omitted methods will be assumed to be GET requests. Supported HTTP methods include:

  • GET
  • POST
  • PUT
  • DELETE

An example call is as follows

espresso generate controller Dog index show create:post update:put delete:delete

The command creates a simple CRUD controller named Dog.

Routing configurations will be generated automatically, and can be viewed in config/routes.js. Views (including style and script assets) will be automatically generated for GET actions.

Generating a model

At this time, espresso doesn't support model generation.

On the other hand, adding your own model modules is extremely easy. Just require() your modules in your controllers and you're good to go.

You're free to use modules for MongoDB, SQL databases, or even just throw your records into memory for smaller projects!

Customizing views

Views are automatically created for GET actions during controller generation.

Starting your server

To start a local server, run the following command

espresso server

You can connect to the localhost on port 50000.

Happy coding!

Having issues? Visit the troubleshooting guide which includes known bugs.