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

vue-crudgen

v1.0.7

Published

TryUs. Software CRUD (Create, Read, Update and Delete) basic generator for Vue.js

Downloads

26

Readme

vue-crudgen

CRUD (Create, Read, Update and Delete) basic generator for Vue.js - Beta.

Coverage Status Build Status Reliability Rating Lines of Code Duplicated Lines (%) Quality gate

The focus this package is front-end with vue.

Next Releases:

  • Vuetify
  • Typescript

Best practices for better RESTful API:

| Resource | GET (Read) | POST (Create) | PUT (Update) | DELETE (Delete) | | ------------- | ------------- |------------- | ------------- |------------- | | /users | Return a list of Users | Create a new User | Bulk Update of Users | Delete all Users | | /users/123 | Returns a Specific User | (405) | Update a Specific User | Delete a Specific User |

Result for a model generate for this tool:

vue-crudgen-laptop with hidpi screen

Install Vue-CLI and Vue-Crudgen.

npm install -g @vue/cli
npm install -g vue-crudgen

How to do?

You need to create a Vue-project and setup your structure of files. My Recomended configuration is: Babel, PWA, Router, Vuex, Eslint and Unit-Jest.

vue create <your-project-name>

IMPORTANT!! Vue crud Generator uses eslint to prettier/vue code. Check dependencies. You need to create or edit an .eslintrc.js file.

//.eslintrc.js
...
'extends': [
  'plugin:prettier/recommended',
  'plugin:vue/essential',
],
...

Now init Vue-Crudgen structure project pattern.

cd <you-root-project-path>
vue-crudgen -i

After run the command just wait some seconds for scaffold and lint. Now you need to create models.

mkdir src/models
cd src/models
touch author.js

Files *.js models objects should be named in singular.

//author.js

const resource = {
  endPoint: "authors"
};

const model = {
  name: {
    type: "text",
    required: true
  },
  birth: {
    type: "date",
    required: true
  },
  active: {
    type: "radio",
    options: [{ id: "Active", value: true }, { id: "Inactive", value: false }]
  },
  sponsor: {
    type: "select",
    options: ["Patreon", "Legacy"]
  }
};

module.exports = { model, resource };

After create a model, execute at command line:

vue-crudgen -m ./src/models/

After run, you will see something like this in your project structure:

project/
├── babel.config.js
├── jest.config.js
├── node_modules
├── package.json
├── package-lock.json
├── public
│   ├── favicon.ico
│   ├── img
│   ├── index.html
│   └── robots.txt
├── README.md
│   ├── src
│   |  ├── App.vue
│   |  ├── assets
│   |  |  └── logo.png
│   |  ├── components
│   |  │   ├── author
│   |  │   └── HelloWorld.vue
│   |  ├── helpers
│   |  │   └── alert.vue
│   |  ├── main.js
│   |  ├── models
│   |  │   └── author.js
│   |  ├── registerServiceWorker.js
│   |  ├── router
│   |  │   └── index.js
│   |  ├── routes
│   |  │   ├── author.js
│   |  │   └── index.js
│   |  ├── services
│   |  │   ├── author.js
│   |  │   └── httpService.js
│   |  ├── store
│   |  │   ├── index.js
│   |  │   └── modules
│   |  └── views
│   |  ├── About.vue
│   |  └── Home.vue
└── tests
    └── unit

You still have to create a .env file with your API base url or edit httpService.js in services directory.

VUE_APP_BASE_URL=http://localhost:8081

Now in your root project, start the app and browse to http://localhost:8080/author.

npm run serve

To test your requests, you can use this repository https://github.com/dionmaicon/books-backend. Follow the instructions in the page and run the backend.

Others models:

//book.js
const resource = {
  endPoint: "books"
};

const model = {
  title: {
    type: "text",
    required: true
  },
  ISBN: {
    type: "number",
    required: true
  },
  authors: {
    type: "oneToMany",
    attribute: "name",
    model: "author"
  },
  publishing: {
    type: "oneToOne",
    attribute: "name",
    model: "publishing"
  },
  year: {
    type: "number",
    required: true
  },
  price: {
    type: "currency"
  },
  fields: {
    type: "hiddenFields",
    options: ["price", "ISBN"]
  }
};
module.exports = { model, resource };
//publishing.js

const resource = {
  endPoint: "publishings"
};

const model = {
  name: {
    type: "text",
    required: true
  }
};

module.exports = { model, resource };