New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mera

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mera

A framework to easily create a REST API from a mongoose model

latest
Source
npmnpm
Version
0.9.1
Version published
Maintainers
1
Created
Source

MERA

Mongoose and Express built RESTful API

Output

As you build a REST API with mera, you get APIs:

  • GET /?querya=xx&queryb=xx&start_time=xx&end_time=xx&_filter=xx&_page=x&_perPage=x
    • Fully supported List
      • Any allowed field can be added as a query field for filtering
      • JSON string can passed in by _filter, if you prefer
      • Use start_time and end_time to filter a time range if timeFilter is set
      • Use _page and _perPage for pagination, X-Total-Count in response head for total count
      • Use _sortDir (ASC|DESC) and _sortField to sort any allowed field
      • Use format= to export a certain format, now supports
        • csv
        • xlsx
        • json (default)
  • GET /:id
    • Get by ID, simply enough
  • POST /
    • Use JSON body to create a new doc; any unknown field or not allowed field will be omitted
  • PUT /:id
    • Use JSON body to update a doc, similar
  • DELETE /:id
    • Delete by ID

Samples

// Create a mongoose model as usual
var mongoose = require('mongoose'), Schema = mongoose.Schema;

var personSchema = new Schema({
  firstName: String,
  lastName: String
});

var Person = mongoose.model('Person', personSchema);

// Create the router with the model
var mera = require('mera');
var router = mera(Person, {
  props: // the properties to be filter at listing, creating or updating
  propsMapping: // [api prop]: [model prop], if any to be mapped, id: '_id' is always added
  baseFilter: // used at listing
  defaultSort: // used at listing
  protects: // { LIST: function(req, cb), GET: , PUT: , ... } // to protect a certain method
  _id: // String, used as { options._id: req.params.id } when /:id is passed in
  omitProps: // [String], list of all props to omit at output, 'output' is always omitted
  uploadProps: // {'upload_file_prop': 'prop_to_be_replaced', }
  timeFilter: // 'field_name', to use this field for time search
  textFields: [String] // field to be search as text, which means using $regex operator
});

app.use('/persons', router); // use in app, all RESTful APIs are available.

and Frontend?

This API is a perfect companion of ng-admin, an Angular based management UI.

You should be able to satify 99% of your management requirements in 1 hour for a model if your db is ready.

Keywords

mongoose

FAQs

Package last updated on 10 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts