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

generator-dcx

v1.2.6

Published

Yeoman generator for creating MEAN stack applications, using MongoDB, Express, AngularJS, and Node

Downloads

22

Readme

Rackspace DCX MEAN generator

Yeoman generator for creating MEAN stack applications, using MongoDB, Express, AngularJS, and Node. Extended from Angular JS + Express Full Stack Generator

Featuring:

  • Express server integrated with grunt tasks
  • Livereload of client and server files
  • Support for Jade and CoffeeScript
  • Easy deployment workflow.
  • Optional MongoDB integration
  • Optional Passport integration for adding user accounts
  • LESS and Twitter Bootstrap3 options

Example project

Coming Soon

Usage

Install generator-dcx:

npm install -g generator-dcx

Make a new directory, and cd into it:

mkdir my-new-project && cd $_

Run yo dcx, optionally passing an app name:

yo dcx [app-name]

Express

Launch your express server in development mode.

grunt serve

Launch your express server in production mode, uses the minified/optimized production folder.

grunt serve:dist

Livereload

grunt serve will watch client files in app/, and server files inside lib/, restarting the Express server when a change is detected.

Deployment

To generate a dist folder that can easily be deployed use:

grunt

This will run unit tests, jshint, concatenate and minify scripts/css, compress images, add css vendor prefixes, and finally copy all files to a tidy dist folder.

Alternatively to skip tests and jshint, use:

grunt build

Heroku Deployment

We provide an extremely simplifed deployment process for heroku.

yo dcx:deploy heroku generates a dist folder that is deployment ready for heroku.com.

Create and Deploy an app in 4 steps

  1. mkdir foo && cd foo

  2. yo dcx

  3. yo dcx:deploy heroku

  4. cd dist && git push heroku master

  5. Optional (if using mongoDB) heroku addons:add mongohq

That's it! Your app should be live and shareable. Type heroku open to view it.

Setting up Route authorization

If your app uses the Passport boilerplate for accounts, you'll of course want to restrict access to certain client routes/api routes.

For protecting server API routes, we can use the auth middleware, which will send a 401 unauthorized error if a user makes a request without being logged in.

For protecting client routes, we automatically handle 401s sent from the server by redirecting you to the login page.

However, as this will load part of the page before redirecting, it will cause a flicker. So this should only be used as a fallback mechanism. A better way to handle restricted pages is to mark the routes on the client side that you want to require authentication for.

You can easily do this from your app.js by adding the following to any client routes that need protecting.

 authenticate: true

This redirects the user to the login page before attempting to load the new route, avoiding the flicker.

Please keep in mind this client routing is only for improving the user interface. Anyone with chrome developer tools can easily get around it and view pages they're not supposed to see.

This is not a problem as long as you secure your server API routes, ensuring that you don't give any sensitive information unless the user is authenticated or authorized.

How do I only let users authorized access an api route?

Similarly to how the auth middleware checks if a user authenticated before going to the next route, you could easily make an ensureAuthorized middleware that checks the users role, or some other field, before sending them to the protected route, otherwise it sends a 403 error.

Generators

Available Angular generators:

Available Fullstack generators:

Note: Generators are to be run from the root directory of your app.

All of the generator-dcx client side generators are available, but aliased using dcx.

They are aliased to ensure the files they generate are added to the correct folders and that the index.(html/jade) is updated properly.

Read more on them from the offical generator angular documentation

Fullstack specific generators

Deploy

Initalizes a heroku app and generates a dist folder which is ready to push to heroku.

Example:

yo dcx:deploy heroku

After app modifications run:

grunt build

then commit and push the dist folder.

Options

In general, these options can be applied to any generator, though they only affect generators that produce scripts.

Jade

For generators that output views, the --jade option will output Jade instead of HTML.

For example:

yo dcx --jade

Changes the rendering engine from EJS to Jade, and generates your views as jade files instead of HTML.

Assets that will be minified or compressed such as scripts, styles, and images, must still use normal html tags so they can be picked up by grunt-usemin and compressed for production builds.

CoffeeScript

For generators that output scripts, the --coffee option will output CoffeeScript instead of JavaScript.

For example:

yo dcx:controller user --coffee

Produces app/scripts/controller/user.coffee:

angular.module('myMod')
  .controller 'UserCtrl', ($scope) ->

A project can mix CoffeScript and JavaScript files.

To output JavaScript files, even if CoffeeScript files exist (the default is to output CoffeeScript files if the generator finds any in the project), use --coffee=false.

Minification Safe

Deprecated

Related Issue #452: This option is being removed in future versions of the generator.

By default, generators produce unannotated code. Without annotations, AngularJS's DI system will break when minified. ngMin is used to add these annotations before minification.

Add to Index

By default, new scripts are added to the index file. However, this may not always be suitable. Some use cases:

  • Manually added to the file
  • Auto-added by a 3rd party plugin
  • Using this generator as a subgenerator

To skip adding them to the index, pass in the skip-add argument:

yo dcx:service serviceName --skip-add

Bower Components

The following packages are always installed by the app generator:

  • angular
  • angular-mocks
  • angular-scenario

The following additional modules are available as components on bower, and installable via bower install:

  • angular-cookies
  • angular-loader
  • angular-resource
  • angular-sanitize

All of these can be updated with bower update as new versions of AngularJS are released.

Testing

Running grunt test will run the unit tests with karma.

Contribute

See the contributing docs

When submitting an issue, please follow the guidelines. Especially important is to make sure Yeoman is up-to-date, and providing the command or commands that cause the issue.

When submitting a PR, make sure that the commit messages match the AngularJS conventions.

License

BSD license

Features to be added

  • sails.js integration
  • e2e testing with protractor
  • integrate with multiple design templates
  • generate api files