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

axes-api

v0.0.5

Published

Axes Api maps your Sequelize models to urls to be accessed for your ExpressJS app.

Downloads

2

Readme

Axes Api GitHub version Build Status Coverage Status Dependency Status

KevinLeighCrain/Js-Axes Axes Api is a Api builder that maps your Sequelize models to urls for your ExpressJS app.

Notes (please read)

  • Axes Api is brand new and soon will have tons upcoming upgrades. (suprises awaits all :P)
  • the current version is so you have a feel of how you define and get started with Axes-Api
  • version 1.0.0 will be out soon!
  • enjoy :)

Installation

$ npm install axes-api

Usage

1) Include Axes Api module to your source

var axes = require('axes-api')

2) Define your Sequelize models to be mapped to url

The recommended way

// define models to be mapped from require
var models = require("../models"); // an example require
axes.define(models);

or

// define a single model to be mapped
axes.define(ExampleModel) // example url http://localhost:3000/examplemodel (will return all ExampleModel);

or

// define multiple models to be mapped 
axes.define(ExampleModel, SecondExampleModel);

or

Warning: by default all your Sequelize model associations, and attributes will be mapped and providing any predefined config will override existing

// define model to be mapped with custom configuration
axes.define({
  model: ExampleModel,
  config: {
    include: [SecondExampleModel], // this will override generated include that Axes-Api provides by default
    attributes: ['id', 'name'] // this will override generated attributes that Axes-Api provides by default
    ...
  }
});

// Example code above will include `SecondExampleModel` for any `ExampleModel` api call based on your `Sequelize` model associations

3) Call apply passing in your express app instance

// will apply HTTP methods to your ExpressJS app
axes.apply(app);

Example urls Axes Api generates for your Sequelize models:

Working with Axes-Api generated urls

Note: Generated urls

  • http://localhost:3000/examplemodel
  • http://localhost:3000/secondexamplemodel/:id?/:name?

Note: Url usage (example using curl)

Example 1) Return all models
// will return all 'ExampleModel' 
curl -i -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:3000/examplemodel
Example 2) Return models passing in optional parameter value (optional parameters are mapped by association/field)
// will return all 'SecondExampleModel' with a 'name' equal to 'test'
curl -i -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:3000/secondexamplemodel?name=test

Dependencies

Version

Current version: 0.0.4

License

Apache-2.0