GithubHelp home page GithubHelp logo

glorious-codes / glorious-crud Goto Github PK

View Code? Open in Web Editor NEW
46.0 46.0 3.0 161 KB

A bare minimum and extensible crud generator

Home Page: https://glorious.codes/crud

JavaScript 100.00%
crud-generator expressjs javascript mongodb nodejs

glorious-crud's Introduction

Glorious Codes

Glorious Codes website

CircleCI Coverage Status

Contributing

  1. Install Node. Download the "Recommend for Most Users" version.

  2. Clone the repo:

git clone [email protected]:glorious-codes/glorious-codes.git
  1. Go to the project directory
cd glorious-codes
  1. Install the project dependencies
npm install
  1. If you want to just build the project, run:
npm run build
  1. Otherwise, run:
npm run start

The app runs on http://localhost:7000. The browser automatically reloads for any source file changes.

Tests

  1. Ensure that all code that you have added is covered with unit tests:
npm run test
  1. You can optionally generate coverage report after running tests:
npm run test -- --coverage

glorious-crud's People

Contributors

rafaelcamargo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

glorious-crud's Issues

Allow basic query params for get requests

Something like:

// resources/base.js
function getAllResources(collection, query, onComplete){
  const filter = buildFilterToGetAllResources(query);
  const order = query.order == 'asc' ? 1 : -1;
  const sort = query.sort ? {[query.sort]: order} : {};
  const limit = query.limit || 0;
  collection.find(filter).sort(sort).limit(parseInt(limit)).toArray((err, result) => {
    onGetComplete(err, result, onComplete);
  });
}

function buildFilterToGetAllResources(query){
  const filter = {};
  for(let key in query) {
    if(shouldAddQueryKeyToFilter(key))
      filter[key] = query[key];
  }
  return filter;
}

Such basic queries will automatically allow requests like that (getting the latest beer saved):
http://localhost:9000/beers?sort=createdAt&order=desc&limit=1

Make GET request navigable

At the moment, get requests respond with all results found. So, requests are taking very long for big amounts of data.
Make pagination enabled by default for any get requests. Suggestion:

  1. List 30 results per page by default
  2. Allow an optional query param called page.
  3. Allow an optional query param called pageSize to change the default value for the number of results per page.
  4. Include a link attribute in response header containing navigation details:
    • e.g.: Link: <https://api.github.com/users?page=2>; rel="next", <https://api.github.com/users?page=50>; rel="last"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.