The IntREST API is simple and easy to use. Has 4 main interfaces:
assetsStream
: The function to get a file stream from theassets
folder, founded in root directory of the project. Receive two parameters:path
: The path of the file inassets
folder.compress
: Possible values aregzip
,deflate
,gzip, deflate
anddeflate, gzip
. If you don't want to compress the file, just set nothing in this parameter.
assetsRawContent
: The function to get a file raw content (Buffer
) from theassets
folder, founded in root directory of the project. Receive two parameters:path
: The path of the file inassets
folder.compress
: Possible values aregzip
,deflate
,gzip, deflate
anddeflate, gzip
. If you don't want to compress the file, just set nothing in this parameter.
assetsContent
: The function to get a file content (string
) from theassets
folder, founded in root directory of the project.parseCompressBuffer
: The function to parse a compressed buffer. Receive two parameters:buffer
: The buffer to parse.encoding
: Is a array of valuesgzip
anddeflate
.
parseCompressStream
: The function to parse a compressed stream piping. Receive two parameters:stream
: The stream to parse.encoding
: Is a array of valuesgzip
anddeflate
.
parseDecompressBuffer
: The function to parse a decompressed buffer. Receive two parameters:buffer
: The buffer to parse.encoding
: Is a array of valuesgzip
anddeflate
.
parseDecompressStream
: The function to parse a decompressed stream piping. Receive two parameters:stream
: The stream to parse.encoding
: Is a array of valuesgzip
anddeflate
.
The IntRequest
interface is the input interface of IntREST. It contains all the information about the request.
method
: The HTTP method of the request. They areGET
,POST
,PUT
,PATCH
,DELETE
.path
: The path of the request.params
: The object of parameters of the request.query
: The object of query parameters of the request. UsingURLSearchParams
API.headers
: The object of headers of the request.body
: The body of the request. It's aobject
.- The
body
property is only available if the request has a body and the method is notGET
. - If the request
Content-Type
ismultipart/form-data
and contains upload files, thebody
property will be contains a file metadata stored with name of the field. The metadata interface isFileMetadata
. - If the request
Content-Type
isapplication/xml
, thebody
property will be contains a object with the XML data following the typeimport('@vulppi/intrest).XMLBody
.
- The
cookies
: The object of cookies of the request. Usingcookie
API.custom
: The object of custom properties of the request. You can use this for share data between middlewares and route handlers.origin
: The origin of the request. It's aobject
containing theurl
andip
properties.url
: The origin URL of the request. It's aURL
object.ip
: The origin IP of the request. It's astring
.
The IntResponse
interface is the output interface of IntREST. It contains all the information about the response.
status
: The HTTP status code of the response.headers
: The object of headers of the response.body
: The body of the response. Can be astring
,object
,Buffer
orReadableStream
.- The
body
property is only available if the response has a body. - If the response
body
is aobject
, theContent-Type
header will be set toapplication/json
if not exists. - If the response
body
is aBuffer
or astring
, theContent-Type
header will be set toplain/text
if not exists. - If the response
body
is aReadableStream
, theContent-Type
header will be set toapplication/octet-stream
if not exists.
- The
cookies
: The object of cookies of the response.clearCookie
: The object of clear cookies of the response.
The MiddlewareNext
interface call the next middleware or route handler. If you send object in this function, the object will be merged with the property custom
of the IntRequest
interface. The MiddlewareNext
return a Promise
with the IntResponse
interface and this response must be returned in the middleware.
custom
: The object of custom properties of the request. You can use this for share data between middlewares and route handlers.