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

sequelize-router

v1.0.6

Published

A restful route generator for Sequelize.

Downloads

23

Readme

Sequelize Router :sunglasses:

An easy to use, RESTful route generator designed to work with Sequelize.

NPM

Why use Sequelize Router?

  • It's tiny (2kb unminified)

  • It's easy to use! You can get up and running in about a minute with almost zero configuration.

  • It's customizable and extensible. Easily override any of the default route controllers.

Installation

Available on npm:

npm install sequelize-router

Prerequisites

  • sequelize-router is middleware that runs on top of sequelize, a popular ORM for node.js applications. Therefore, make sure that you have configured a database prior to use.

  • (Optional) Consider using sequelize-cli to quickly scaffold models of your database to be used for even quicker deployement:

$ npm install --save-dev sequelize-cli
$ npm install --save sequelize
$ sequelize init:config init:models

Usage

var express = require('express');
// Require the sequelize-router middleware and any models to be used
var sequelizeRouter = require('sequelize-router');
var db = require('./models');

var app = express();
// Use the sequelize-router middleware as shown below
app.use('/api', sequelizeRouter(db.Inventory)); 
app.use('/api', sequelizeRouter(db.Store));
app.use('/api', sequelizeRouter(db.Transaction));

That's literally it. :boom: Restful API Routes are now created for three models.

  • In the example above, RESTful API routes are being created for the Inventory, Store and Transaction models. Model names are lowercased and used to construct endpoints.

API Documentation

| HTTP method | URL | Description | | :-------------: | ------------------------------------------- | ------------------------------- | | GET | /api/inventory | Runs a findAll query on the inventory table, additionally filterable with optional query parameters. *e.g. /api/inventory?stock%5Blte%5D=50 or /api/inventory?category=home_improvement | | GET | /api/inventory/:id | Runs a findOne query on the inventory table and retrieves one record with the id specified in req.params.id. | | POST | /api/inventory/ | Runs a create query on the inventory table, using data passed in req.body to construct the new record. | | PUT | /api/inventory/:id | Runs an update query on the inventory table, using data passed in req.body to update the record with the id specified in req.params.id. By default, query parameters are ignored.| |DELETE | /api/inventory/:id | Runs an destroy query on the inventory table, using data passed in req.body to update the record with the id specified in req.params.id. By default, query parameters are ignored. |

Defaults

  • By default, each endpoint responds with the data retrieved from the Sequelize query, or from the error returned.

  • Defaults are can be easily overridden for any model's methods by passing a configuration object into the sequelize-router middleware. Further documentation on this to come.

Authors

Christian Eckenrode

Contributors