Manual Reference Source Test
import IContentController from 'pop-api/src/controllers/IContentController.js'
public interface | source

IContentController

Extends:

IController → IContentController

Direct Subclass:

BaseContentController

Implements:

Direct Implemented:

Interface for handling the content endpoints.

Test:

Method Summary

Public Methods
public abstract

Create a new content item.

public abstract

Delete a content item.

public abstract

Get a content item based on the id.

public abstract

Default method to get content pages.

public abstract

Default method to get a page of content.

public abstract

Default method to get a random content item.

public abstract

sortContent(sort: string, order: number): Object

Default method to sort the items.

public abstract

Update the info of one content item.

Inherited Summary

From class IController
public abstract

registerRoutes(router: Object, PopApi: PopApi): undefined

Default method to register the routes.

Public Methods

public abstract createContent(req: IncomingMessage, res: ServerResponse, next: Function): Promise<Object, Error> source

Create a new content item.

Params:

NameTypeAttributeDescription
req IncomingMessage
  • nullable: false

The incoming message request object.

res ServerResponse
  • nullable: false

The server response object.

next Function
  • nullable: false

The next function to move to the next middleware.

Return:

Promise<Object, Error>

The created content item.

Throw:

Error

Using default method: 'createContent'.

Test:

public abstract deleteContent(req: IncomingMessage, res: ServerResponse, next: Function): Promise<Object, Error> source

Delete a content item.

Params:

NameTypeAttributeDescription
req IncomingMessage
  • nullable: false

The incoming message request object.

res ServerResponse
  • nullable: false

The server response object.

next Function
  • nullable: false

The next function to move to the next middleware.

Return:

Promise<Object, Error>

The deleted content item

Throw:

Error

Using default method: 'deleteContent'.

Test:

public abstract getContent(req: IncomingMessage, res: ServerResponse, next: Function): Promise<Object, Error> source

Get a content item based on the id.

Params:

NameTypeAttributeDescription
req IncomingMessage
  • nullable: false

The incoming message request object.

res ServerResponse
  • nullable: false

The server response object.

next Function
  • nullable: false

The next function to move to the next middleware.

Return:

Promise<Object, Error>

The details of a single content item.

Throw:

Error

Using default method: 'getContent'.

Test:

public abstract getContents(req: IncomingMessage, res: ServerResponse, next: Function): Promise<Array<string>, Object> source

Default method to get content pages.

Params:

NameTypeAttributeDescription
req IncomingMessage
  • nullable: false

The incoming message request object.

res ServerResponse
  • nullable: false

The server response object.

next Function
  • nullable: false

The next function to move to the next middleware.

Return:

Promise<Array<string>, Object>

A list of pages which are available.

Throw:

Error

Using default method: 'getContents'.

Test:

public abstract getPage(req: IncomingMessage, res: ServerResponse, next: Function): Promise<Array<Object>, Error> source

Default method to get a page of content.

Params:

NameTypeAttributeDescription
req IncomingMessage
  • nullable: false

The incoming message request object.

res ServerResponse
  • nullable: false

The server response object.

next Function
  • nullable: false

The next function to move to the next middleware.

Return:

Promise<Array<Object>, Error>

The content of one page.

Throw:

Error

Using default method: 'getPage'.

Test:

public abstract getRandomContent(req: IncomingMessage, res: ServerResponse, next: Function): Promise<Object, Error> source

Default method to get a random content item.

Params:

NameTypeAttributeDescription
req IncomingMessage
  • nullable: false

The incoming message request object.

res ServerResponse
  • nullable: false

The server response object.

next Function
  • nullable: false

The next function to move to the next middleware.

Return:

Promise<Object, Error>

A random item.

Throw:

Error

Using default method: 'getRandomContent'.

Test:

public abstract sortContent(sort: string, order: number): Object source

Default method to sort the items.

Params:

NameTypeAttributeDescription
sort string
  • nullable: false

The property to sort on.

order number
  • nullable: false

The way to sort the property.

Return:

Object

The sort object.

Throw:

Error

Using default method: 'sortContent'

Test:

public abstract updateContent(req: IncomingMessage, res: ServerResponse, next: Function): Promise<Object, Error> source

Update the info of one content item.

Params:

NameTypeAttributeDescription
req IncomingMessage
  • nullable: false

The incoming message request object.

res ServerResponse
  • nullable: false

The server response object.

next Function
  • nullable: false

The next function to move to the next middleware.

Return:

Promise<Object, Error>

The updated content item.

Throw:

Error

Using default method: 'updateContent'.

Test: