validated-request
Prevent your system from sending request with incorect parameters
use case
- Sending log data to a logging server that provides analysis tools on the log
var ValidatedRequest = ;// protocol says that we can only make GET requestsvar validatedRequest = method: 'GET' headers: 'Content-Type': 'string' ; var url = '<host>/api' headers = 'Content-Type': 'application/json' body = request: 'what can you do' response: 'I can tell you a joke!' ; validatedRequest // this will work!validatedRequest // this will NOT work because aggrement is that the system should only make GET requests
api
- Sending get request
var ValidatedRequest = ;// protocol says that we can only make GET requestsvar validatedRequest = method: 'GET' query: 'userId': 'string' limit: 'number' headers: 'Content-Type': 'string' ; var url = '<host>/api?userId=mars&limit=10' headers = 'Content-Type': 'application/json' ; validatedRequest // @return Promise.resolve<{ response, body }>// @return Promise.reject<{ response, error }>
- Sending post request
var ValidatedRequest = ;// protocol says that we can only make POST requestsvar validatedRequest = method: 'POST' headers: 'Content-Type': 'string' body: request: 'string' response: 'string' ; var url = '<host>/api' headers = 'Content-Type': 'application/json' body = request: 'what can you do' response: 'I can tell you a joke!' ; validatedRequest// @return Promise.resolve<{ response, body }>// @return Promise.reject<{ response, error }>