Bumps [dotenv](https://github.com/motdotla/dotenv) from 17.2.2 to 17.2.3. - [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md) - [Commits](https://github.com/motdotla/dotenv/compare/v17.2.2...v17.2.3) --- updated-dependencies: - dependency-name: dotenv dependency-version: 17.2.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
news-server
An API centric news server. Uses Sequelize and mariaDB by default.
This server is available via docker hub at krgamestudios/news-server.
Setup
There are multiple ways to run this app - it can run on it's own via npm start (for production) or npm run dev (for development). it can also run inside docker using docker compose up --build - run node configure-script.js to generate docker-compose.yml and startup.sql.
To generate an authorization token, use auth-server. A public-facing development auth-server is available here (tokens are valid for 10 minutes):
POST https://dev-auth.krgamestudios.com/auth/login HTTP/1.1
Content-Type: application/json
{
"email": "example@example.com",
"password": "helloworld"
}
API
GET /news/:id?
Get either an array of articles (newest first), or a specified article if the optional "id" parameter is given.
Response Body
[{
// [Number] index of the article
"index": index,
// [String] author of the article
"author": author,
// [String] raw body of the article
"body": body,
// [Number] number of times this article has been edited
"edits": edits,
// [String] body of the article rendered as HTML
"rendered": rendered,
// [String] title of the article
"title": title,
// [Date] time article was created
"createdAt": createdAt,
// [Date] time article was updated
"updatedAt": updatedAt,
}]
Available Query Parameters
fields- TYPE:
stringA comma separated list of the field names you want returning, (index will always be returned)
- TYPE:
page- TYPE:
numberThe current page you want returning
- TYPE:
page_size- TYPE:
numberThe number of results to return. This superseeds thePAGE_SIZEenvironment variable for the query
- TYPE:
Note
If a specific article is requested, then just that article is returned rather than an array
GET /news/archive/:id?
Get either an array of articles (oldest first), or a specified article if the optional "id" parameter is given.
Response Body
[{
// [Number] index of the article
"index": index,
// [String] author of the article
"author": author,
// [String] raw body of the article
"body": body,
// [Number] number of times this article has been edited
"edits": edits,
// [String] body of the article rendered as HTML
"rendered": rendered,
// [String] title of the article
"title": title,
// [Date] time article was created
"createdAt": createdAt,
// [Date] time article was updated
"updatedAt": updatedAt,
}]
Available Query Parameters
fields- TYPE:
stringA comma separated list of the field names you want returning, (index will always be returned)
- TYPE:
page- TYPE:
numberThe current page you want returning
- TYPE:
page_size- TYPE:
numberThe number of results to return. This superseeds thePAGE_SIZEenvironment variable for the query
- TYPE:
Note
If a specific article is requested, then just that article is returned rather than an array
GET /news/metadata/:id?
Get either an array of metadata (newest first), or a specified article's metadata if the optional "id" parameter is given.
Response Body
[{
// [Number] index of the article
"index": index,
// [String] author of the article
"author": author,
// [Number] number of times this article has been edited
"edits": edits,
// [String] title of the article
"title": title,
// [Date] time article was created
"createdAt": createdAt,
// [Date] time article was updated
"updatedAt": updatedAt,
}]
Available Query Parameters
fields- TYPE:
stringA comma separated list of the field names you want returning, (index will always be returned)
- TYPE:
page- TYPE:
numberThe current page you want returning
- TYPE:
page_size- TYPE:
numberThe number of results to return. This superseeds thePAGE_SIZEenvironment variable for the query
- TYPE:
Note
If a specific article is requested, then just that article is returned rather than an array
GET /news/archive/metadata/:id?
Get either an array of metadata (oldest first), or a specified article's metadata if the optional "id" parameter is given.
Response Body
[{
// [Number] index of the article
"index": index,
// [String] author of the article
"author": author,
// [Number] number of times this article has been edited
"edits": edits,
// [String] title of the article
"title": title,
// [Date] time article was created
"createdAt": createdAt,
// [Date] time article was updated
"updatedAt": updatedAt,
}]
Available Query Parameters
fields- TYPE:
stringA comma separated list of the field names you want returning, (index will always be returned)
- TYPE:
page- TYPE:
numberThe current page you want returning
- TYPE:
page_size- TYPE:
numberThe number of results to return. This supersedes thePAGE_SIZEenvironment variable for the query
- TYPE:
Note
If a specific article is requested, then just that article is returned rather than an array
POST /news
Important
Requires valid JWT Authorization header (Authorization: Bearer XXX)
Create a new article resource, returns either the new article's index on success, or an error on failure.
Request Body
{
// [String] OPTIONAL: title of the article
"title": title,
// [String] OPTIONAL: author of the article
"author": author,
// [String] OPTIONAL: body of the article
"body": body,
}
Response Body
{
// [Number]: new index of the article
"index": index,
}
PATCH /news/:id
Important
Requires valid JWT Authorization header (Authorization: Bearer XXX)
Update an existing article resource, returns either status code 200 on success, or an error status on failure.
Request Body
{
// [String] OPTIONAL: title of the article
"title": title,
// [String] OPTIONAL: author of the article
"author": author,
// [String] OPTIONAL: body of the article
"body": body,
}
DELETE /news/:id
Important
Requires valid JWT Authorization header (Authorization: Bearer XXX)
Remove an existing article resource from the news feed, returns either status code 200 on success, or an error status on failure.