Module: api/news

Methods

(async, inner) deleteNewsEntry(request, response)

Delete news specified by Un*x Timestamp

Parameters:
Name Type Description
request Object
Properties
Name Type Description
query.target number

Un*x timestamp to identify the entry

response Object
Source:
Returns:

result is logged into console

Example
$ curl -X DELETE \
      http://localhost:3001/api/news?target=0
// Delete news posted on Un*x Epoch

(async, inner) getNewsEntry(request, response) → {JSON}

Get single news entry specified by Un*x Timestamp

Parameters:
Name Type Description
request Object
Properties
Name Type Description
query.target number

Un*x Timestamp to specify news entry

response Object
Source:
Returns:

news entry data

Type
JSON
Example
$ curl -X GET http://localhost:3001/api/news?target=0
// gets news posted on Un*x epoch in JSON format

(async, inner) getNewsList(request, response) → {string}

Get news list in HTML table body tr+td

Parameters:
Name Type Description
request Object
response Object
Source:
Returns:

HTML table body tr+td

Type
string
Example
$ curl -X GET \
      http://localhost:3001/api/news/list
// <tr>
//     <td>1</td>
//     <td>1970/1/1 0:0:0</td>
//     ...
// </tr>
// ...

(async, inner) getNewsListUnrwapped(request, response) → {JSON}

Get news list in unformated raw JSON string

Parameters:
Name Type Description
request Object
response Object
Source:
Returns:

Unformatted JSON string that contains news entries

Type
JSON
Example
$ curl -X GET \
      http://localhost:3001/api/news/list-unwrapped
// gets raw JSON containing news entries

(async, inner) postNewsEntry(request, response)

Post news and write to database

Parameters:
Name Type Description
request Object
Properties
Name Type Description
body.entryType number

Number that represents type of news (0: article, 1: tweet)

body.cardContent string

Content of news card, Markdown is allowed

body.article string

Article written in Markdown

body.linkPath string

Relative URL path to the article

body.coverImagePath string

Relative URL path to the cover image

response Object
Source:
Returns:

result is logged into console

Example
$ curl -X POST \
      -H 'Content-Type: application/x-www-form-urlencoded' \
      --data-raw 'entryType=1&cardContent=Test&article=&linkPath=&coverImagePath=/default.png' \
      http://localhost:3001/api/news
// Posts Tweet style news with content "Test" and cover image "/default.png"

(async, inner) putNewsEntry(request, response)

Update news entry

Parameters:
Name Type Description
request Object
Properties
Name Type Description
body.target number

Un*x timestamp to identify the entry

body.entryType number

Number that represents type of news (0: article, 1: tweet)

body.cardContent string

Content of news card, Markdown is allowed

body.article string

Article written in Markdown

body.linkPath string

Relative URL path to the article

body.coverImagePath string

Relative URL path to the cover image

response Object
Source:
Returns:

result is logged into console

Example
$ curl -X PUT \
      -H 'Content-Type: application/x-www-form-urlencoded' \
      --data-raw 'target=0&entryType=1&cardContent=Test&article=&linkPath=&coverImagePath=default.png' \
      http://localhost:3001/api/news
// Update news posted on Un*x Epoch with given contents