merest
Version:
Express based REST-full API for Mongoose models
1,329 lines (449 loc) • 16.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>Class: ModelAPIRouter | Merest</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: ModelAPIRouter</h1>
<section>
<header>
<h2>ModelAPIRouter</h2>
<div class="class-description">ModelAPIRouter - express router dispatches REST-calls to api-controllers</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="ModelAPIRouter"><span class="type-signature"></span>new ModelAPIRouter<span class="signature">(model, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="ModelAPIRouter.html">ModelAPIRouter</a>}</span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>model</code></td>
<td class="type">
<span class="param-type">mongoose.Model</span>
|
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">model to be exposed</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">router configuration object
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">options for OPTIONS http-method</td>
</tr>
<tr>
<td class="name"><code>create</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">options for CREATE REST-method</td>
</tr>
<tr>
<td class="name"><code>search</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">options for SEARCH(LIST) REST-method</td>
</tr>
<tr>
<td class="name"><code>details</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">options for DETAILS REST-method</td>
</tr>
<tr>
<td class="name"><code>update</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">options for UPDATE REST-method</td>
</tr>
<tr>
<td class="name"><code>delete</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">options for DELETE REST-method</td>
</tr>
<tr>
<td class="name"><code>expose</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">options for exposing methods of model</td>
</tr>
<tr>
<td class="name"><code>exposeStatic</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">options for exposing static model methods</td>
</tr>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the path to mount router (levels: router|METHOD)</td>
</tr>
<tr>
<td class="name"><code>filter</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the mongodb-filter object or function that returns the same type object (levels: router|METHOD)</td>
</tr>
<tr>
<td class="name"><code>fields</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the mongodb-fields descriptor (levels: router|METHOD)</td>
</tr>
<tr>
<td class="name"><code>queryFields</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the object with keys that defines allow to use field in query or not</td>
</tr>
<tr>
<td class="name"><code>popuplate</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Object</span>
|
<span class="param-type">Array</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the mongoose population descriptor (levels: router|METHOD)</td>
</tr>
<tr>
<td class="name"><code>skip</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the flag to allow or deny skipping documents (levels: router|METHOD)</td>
</tr>
<tr>
<td class="name"><code>limit</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the flag to allow or deny limit documents number (levels: router|METHOD)</td>
</tr>
<tr>
<td class="name"><code>sort</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the flag or an object that defines fields to be used for documents corting (levels: router|METHOD)</td>
</tr>
<tr>
<td class="name"><code>middlewares</code></td>
<td class="type">
<span class="param-type">function</span>
|
<span class="param-type">Array</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the Function or Array of Function that should be called before the router controller will be called (levels: router|METHOD)</td>
</tr>
<tr>
<td class="name"><code>matchId</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">RegExp</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the String or RegExp that allows to identify values of _id to build correct routing paths</td>
</tr>
<tr>
<td class="name"><code>title</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">the short description of the path</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="model-api-router.js.html">model-api-router.js</a>, <a href="model-api-router.js.html#line42">line 42</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
created router
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="ModelAPIRouter.html">ModelAPIRouter</a></span>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="attachTo"><span class="type-signature"></span>attachTo<span class="signature">(app)</span><span class="type-signature"> → {<a href="ModelAPIRouter.html">ModelAPIRouter</a>}</span></h4>
<div class="description">
ModelAPIRouter.prototype.attachTo - attaches the router to the ModelAPIExpress
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>app</code></td>
<td class="type">
<span class="param-type"><a href="ModelAPIExpress.html">ModelAPIExpress</a></span>
</td>
<td class="description last">the API Application to which the router should be mounted</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="model-api-router.js.html">model-api-router.js</a>, <a href="model-api-router.js.html#line150">line 150</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
self
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="ModelAPIRouter.html">ModelAPIRouter</a></span>
</dd>
</dl>
<h4 class="name" id="urls"><span class="type-signature"></span>urls<span class="signature">(rootPath)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
ModelAPIRouter.prototype.urls - returns avaliable urls
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>rootPath</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">the path to the router (before it)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="model-api-router.js.html">model-api-router.js</a>, <a href="model-api-router.js.html#line171">line 171</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the list of avaliable urls
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
</article>
</section>
</div>
<nav><h2>
<a href="index.html">merest</a>
</h2>
<h3><a href="installation.html">Installation</a></h3>
<ul>
<li><a href="installation.html#prerequisites">Prerequisites</a></li>
<li><a href="installation.html#npm-install">npm installation</a></li>
<li><a href="installation.html#development">Development</a></li>
</ul>
<h3><a href="cook-book.html">Cook-book</a></h3>
<h3><a href="conf-levels.html">API Configuration</a></h3>
<ul>
<li><a href="conf-levels.html">Configuration levels</a></li>
<li><a href="conf-app.html">API Application</a></li>
<li><a href="conf-router.html">Router</a></li>
<li><a href="conf-end-points.html">End-point</a></li>
<li><a href="conf-methods.html">Model methods</a></li>
</ul>
<h3><a href="end-points.html">API Requests and Responses</a></h3>
<ul>
<li><a href="end-points.html">Common reponses</a></li>
<li><a href="end-points.html#ep_options">Options</a></li>
<li><a href="end-points.html#ep_search">Search</a></li>
<li><a href="end-points.html#ep_create">Create</a></li>
<li><a href="end-points.html#ep_details">Details</a></li>
<li><a href="end-points.html#ep_update">Update</a></li>
<li><a href="end-points.html#ep_delete">Delete</a></li>
<li><a href="end-points.html#transform-response">Custom response</a></li>
</ul>
<h3><a href="swagger.html">Swagger support</a></h3>
<ul>
<li><a href="swagger.html#install">Installation</a></li>
<li><a href="swagger.html#api-conf">Configure API</a></li>
<li><a href="swagger.html#document">Creating <code>swagger.json</code></a></li>
<li><a href="swagger.html#api-docs">Exposing the api-docs</a></li>
<li><a href="swagger.html#swagger-ui">Embedded swagger-ui</a></li>
</ul>
<h3>Specifications</h3>
<ul>
<li><a href="ModelAPIExpress.html">ModelAPIExpress</a></li>
<li><a href="merest-swagger.html">Swagger-support methods</a></li>
<li><a href="ModelAPIRouter.html">ModelAPIRouter</a></li>
<li><a href="ModelAPIError.html">ModelAPIError</a></li>
</ul>
</nav>
<br class="clear">
<footer>
Documentation generated with <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>