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-angular-crud

v0.0.4

Published

Angular CRUD generator

Downloads

4

Readme

generator-angular-crud

generator-angular-crud is a yeoman generator based on the great John Papa's hottowel generator. This generator generates the code using the Angular Style Guide written by John Papa. The generated code is based in a proven structure and conventions for developing Angular applications.

generator-angular-crud allows creating entities and CRUD operations very productively.

Currently, this generator is adapted for working with a Sails backend, although it's very easy to adapt it for working with whatever backend.

The generator allows creating entities automatically in a table form from where you can create, read, update and remove each database record.

Demo Application

You can see a demo application developed with generator-angular-crud at Angular CRUD Demo

Video Tutorial

Angular CRUD

Backend with Sails

At first place, you will have to create your API with Sails. However, when you get a list of records, Sails won't give you information regarding the total records, so you can't paginate properly. For example, if I request this: http://localhost:1337/customer, I get the following information:

[
  {
    code: 'customer 1'
  },
  {
    code: 'customer 2'
  },
  {
    code: 'customer 3'
  }
]

But if I have to paginate I need information regarding the total number of records. So, I have to override the find blueprint. To do this, you have to copy from this project the file sails/api/blueprints/find.js into your ROOT_PROJECT/api/blueprints/find.js. Now, if I request this: http://localhost:1337/customer, I will get the following information:

{
  total: 1000,
  results: [
    {
      code: 'customer 1'
    },
    {
      code: 'customer 2'
    },
    {
      code: 'customer 3'
    }
  ]
}

With this object we have all the information that we need to paginate.

Next steps that you have to do with Sails are:

  • npm install lodash --save
  • update config/models to enable the following parameter: migrate: 'alter'
  • update config/cors to set allRoutes: true and origin: '*'
  • generate your api with sails generate api

Frontend Quickstart

You will need to install generator-angular-crud:

$ npm install -g generator-angular-crud

You have to create a new folder for your project and from this folder you will generate your application:

$ yo angular-crud

Next, you will create a new feature, a customer, for example:

$ yo angular-crud:feature <customer>

This will create an AngularJS application supporting full CRUD functionality.

This subgenerator will create an entity with two properties called 'name' and 'street'. If we want to add new properties to our entity, we weed to follow these steps:

  • Add new properties to the angular-formly array properties in src/client/app/feature-name/services/feature-name.form.client.service.js
  • Add new columns for the new properties in the HTML table in src/client/app/feature-name/views/list.html

TODO

  • Improve validation errors returned by the server
  • Websockets to get realtime notifications
  • Adaptors for different backends (Firebase, Backand, ...)
  • Testing

License

MIT