Files
sera-new-hp/src-manager/docs/manager/1.0.0/module-api_news.html

1598 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: api/news</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">Module: api/news</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="~deleteNewsEntry"><span class="type-signature">(async, inner) </span>deleteNewsEntry<span class="signature">(request, response)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Delete news specified by Un*x Timestamp</p>
</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>request</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>query.target</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Un*x timestamp to identify the entry</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>response</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_news.js.html">api/news.js</a>, <a href="api_news.js.html#line168">line 168</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>result is logged into console</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>$ curl -X DELETE \
http://localhost:3001/api/news?target=0
// Delete news posted on Un*x Epoch</code></pre>
<h4 class="name" id="~getNewsEntry"><span class="type-signature">(async, inner) </span>getNewsEntry<span class="signature">(request, response)</span><span class="type-signature"> &rarr; {JSON}</span></h4>
<div class="description">
<p>Get single news entry specified by Un*x Timestamp</p>
</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>request</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>query.target</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Un*x Timestamp to specify news entry</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>response</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_news.js.html">api/news.js</a>, <a href="api_news.js.html#line40">line 40</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>news entry data</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">JSON</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>$ curl -X GET http://localhost:3001/api/news?target=0
// gets news posted on Un*x epoch in JSON format</code></pre>
<h4 class="name" id="~getNewsList"><span class="type-signature">(async, inner) </span>getNewsList<span class="signature">(request, response)</span><span class="type-signature"> &rarr; {string}</span></h4>
<div class="description">
<p>Get news list in HTML table body tr+td</p>
</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>request</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>response</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_news.js.html">api/news.js</a>, <a href="api_news.js.html#line211">line 211</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>HTML table body tr+td</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>$ curl -X GET \
http://localhost:3001/api/news/list
// &lt;tr>
// &lt;td>1&lt;/td>
// &lt;td>1970/1/1 0:0:0&lt;/td>
// ...
// &lt;/tr>
// ...</code></pre>
<h4 class="name" id="~getNewsListUnrwapped"><span class="type-signature">(async, inner) </span>getNewsListUnrwapped<span class="signature">(request, response)</span><span class="type-signature"> &rarr; {JSON}</span></h4>
<div class="description">
<p>Get news list in unformated raw JSON string</p>
</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>request</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>response</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_news.js.html">api/news.js</a>, <a href="api_news.js.html#line252">line 252</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Unformatted JSON string that contains news entries</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">JSON</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>$ curl -X GET \
http://localhost:3001/api/news/list-unwrapped
// gets raw JSON containing news entries</code></pre>
<h4 class="name" id="~postNewsEntry"><span class="type-signature">(async, inner) </span>postNewsEntry<span class="signature">(request, response)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Post news and write to database</p>
</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>request</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>body.entryType</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Number that represents type of news (0: article, 1: tweet)</p></td>
</tr>
<tr>
<td class="name"><code>body.cardContent</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>Content of news card, Markdown is allowed</p></td>
</tr>
<tr>
<td class="name"><code>body.article</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>Article written in Markdown</p></td>
</tr>
<tr>
<td class="name"><code>body.linkPath</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>Relative URL path to the article</p></td>
</tr>
<tr>
<td class="name"><code>body.coverImagePath</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>Relative URL path to the cover image</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>response</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_news.js.html">api/news.js</a>, <a href="api_news.js.html#line81">line 81</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>result is logged into console</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>$ curl -X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-raw 'entryType=1&amp;cardContent=Test&amp;article=&amp;linkPath=&amp;coverImagePath=/default.png' \
http://localhost:3001/api/news
// Posts Tweet style news with content "Test" and cover image "/default.png"</code></pre>
<h4 class="name" id="~putNewsEntry"><span class="type-signature">(async, inner) </span>putNewsEntry<span class="signature">(request, response)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Update news entry</p>
</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>request</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>body.target</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Un*x timestamp to identify the entry</p></td>
</tr>
<tr>
<td class="name"><code>body.entryType</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Number that represents type of news (0: article, 1: tweet)</p></td>
</tr>
<tr>
<td class="name"><code>body.cardContent</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>Content of news card, Markdown is allowed</p></td>
</tr>
<tr>
<td class="name"><code>body.article</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>Article written in Markdown</p></td>
</tr>
<tr>
<td class="name"><code>body.linkPath</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>Relative URL path to the article</p></td>
</tr>
<tr>
<td class="name"><code>body.coverImagePath</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>Relative URL path to the cover image</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>response</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_news.js.html">api/news.js</a>, <a href="api_news.js.html#line125">line 125</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>result is logged into console</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>$ curl -X PUT \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-raw 'target=0&amp;entryType=1&amp;cardContent=Test&amp;article=&amp;linkPath=&amp;coverImagePath=default.png' \
http://localhost:3001/api/news
// Update news posted on Un*x Epoch with given contents</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-api_gallery-image.html">api/gallery-image</a></li><li><a href="module-api_news.html">api/news</a></li><li><a href="module-utils_asyncDatabase.html">utils/asyncDatabase</a></li><li><a href="module-utils_tableWrapper.html">utils/tableWrapper</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Tue Nov 26 2024 23:18:12 GMT+0900 (日本標準時)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>