Skip to content

Module: REST

Aviril edited this page Sep 6, 2022 · 9 revisions

━ What's the Objective?

REST APIs are software interface that allows you to GET, PUT, POST & DELETE data via HTTP(s) queries and establish connection b/w client & the server. It’s based on RESTful technology, an architectural style, and a communication strategy that’s common in web services development. Rest APIs are widely used due to its flexibility, scalability and ease of integration in everyday web applications. However, express-js doesn't let you create/destroy dynamically allocated REST APIs which can be achieved via vNetwork's REST API implementation.

━ APIs

━ server.rest.fetch() (Shared)

@Objective: Requests a fetch on specified API.
const object: result = server.rest.fetch(
  string: type, // Type could be either of "post", "get", "put", "delete"
  string: route,
  object: data // Required for "post" & "put" types
)

━ server.rest.isVoid() (Server)

@Objective: Validates whether the route is void.
const bool: isRouteVoid = server.rest.isVoid(
  string: type,
  string: route
)

━ server.rest.create() (Server)

@Objective: Creates a new API w/ the specified options.
const bool: state = server.rest.create(
  string: type, // Type could be either of "post", "get", "put", "delete"
  string: route,
  function: exec // Route's request handler
)

━ server.rest.destroy() (Server)

@Objective: Destroys an existing API.
const bool: state = server.rest.destroy(
  string: type,
  string: route
)

━ server.rest.onMiddleware() (Server) (📅Event)

@Objective: Middleware for the interface.
⚠️ By default its all pre-configured, it is unlikely that you may need it unless you want to override the middleware.
server.rest.onMiddleware = function(
  object: request,
  object: response,
  function: next
) {}

━ Glossary

━ Modules

Clone this wiki locally