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

loopback-console-cs

v1.0.0

Published

A command-line tool for Loopback app debugging and administration with coffee-script

Downloads

166

Readme

loopback-console-cs

A command-line tool for Loopback app debugging and administration with CoffeeScript.

The loopback-console-cs is a command-line tool for interacting with your Loopback app. It works like the built-in CoffeeScript REPL, but provides a handful of features that are helpful when debugging or generally working within your app's environment. Features include,

  • Easy availability of your app's models and important handles. See Available Handles
  • Automatic promise resolution, for intuitive access to Loopback ORM responses.

Installation

The console can be used easily by just installing it and running its binary:

   npm install loopback-console-cs --save
   $(npm bin)/loopback-console-cs

Assuming you install it within your project, the default setup will detect your project's location and bootstrap your app based on your current working directory. if you'd instead like to load a specific app in the console, execute it with a path to the app's main script:

   loopback-console-cs [path/to/server/server.js]

The recommended configuration is to add the console to your package.json scripts, as follows:

  "scripts": {
    "console": "loopback-console-cs"
  }

Once added you may launch the console by running,

   npm run console

Examples

The loopback-console-cs makes it easy to work with your Loopback models.

loopback > .models
User, AccessToken, ACL, RoleMapping, Role, Widget
loopback > Widget.count()
0
loopback > Object.keys Widget.definition.properties
[ 'name', 'description', 'created', 'id' ]
loopback > w = Widget.create name: 'myWidget01', description: 'My new Widget'
{ name: 'myWidget01', description: 'My new Widget', id: 1 }
loopback > Widget.count()
1
loopback > w.name = 'super-widget'
'super-widget'
loopback > w.save()
{ name: 'super-widget', description: 'My new Widget' }
loopback > Widget.find()
[ { name: 'super-widget', description: 'My new Widget', id: 1 } ]

Multi-line Mode


# Enter multiline mode with either Ctrl + V (OSX) or Win + V (Windows

........ >  AccessToken.find().then (tokens) ->
........ >   console.log tokens
........ >
........ >   AccessToken.deleteById(tokens[0].id).then (res) ->
........ >     console.log 'token deleted', res

# Finish and exit multiline mode with either Ctrl + V (OSX) or Win + V (Windows

Available Handles

By default the loopback-console-cs provides a few handles designed to make it easier to work with your project,

  • Models: All of your app's Loopback models are available directly. For example, User. Type .models to see a list.
  • app: The Loopback app handle.
  • cb: A simplified callback function that,
    • Has signature function (err, result)
    • Stores results on the REPL's result handle.
    • Prints errors with console.error and results with console.log
  • result: The storage target of the cb function

Advanced Setup

In some cases you may want to perform operations each time the console loads to better integrate it with your app's environment.

To integrate loopback-console-cs with your app the following additions must be made to your app's server/server.js file,

  1. Include the library: LoopbackConsole = require 'loopback-console-cs'
  2. Integrate it with server execution:
# LoopbackConsole.activated() checks whether the conditions are right to launch
# the console instead of the web server. The console can be activated by passing
# the argument --console or by setting env-var LOOPBACK_CONSOLE=1
if LoopbackConsole.activated()
  LoopbackConsole.start app,
    prompt: "my-app # "
    # Other REPL or loopback-console-cs config
else if require.main is module
  app.start()

Configuration

By integrating the loopback-console-cs you also gain the ability to configure its functionality. The following configuration directives are supported,

  • quiet: Suppresses the help text on startup and the automatic printing of result.
  • historyPath: The path to a file to persist command history. Use an empty string ('') to disable history.
  • All built-in configuration options for Node.js REPL, such as prompt.
  • handles: Disable any default handles, or pass additional handles that you would like available on the console.

Note, command history path can also be configured with the env-var LOOPBACK_CONSOLE_HISTORY.

Contributors

  • Nathan Bolam (BoLaMN)

A Special thanks to Heath Morrison (doublemarked) for creating loopback-console which this is based on.

License

loopback-console-cs uses the MIT license. See LICENSE for more details.