The IntREST API is simple and easy to use. Has 4 main interfaces:
assetsStream: The function to get a file stream from theassetsfolder, founded in root directory of the project. Receive two parameters:path: The path of the file inassetsfolder.compress: Possible values aregzip,deflate,gzip, deflateanddeflate, 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 theassetsfolder, founded in root directory of the project. Receive two parameters:path: The path of the file inassetsfolder.compress: Possible values aregzip,deflate,gzip, deflateanddeflate, 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 theassetsfolder, 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 valuesgzipanddeflate.
parseCompressStream: The function to parse a compressed stream piping. Receive two parameters:stream: The stream to parse.encoding: Is a array of valuesgzipanddeflate.
parseDecompressBuffer: The function to parse a decompressed buffer. Receive two parameters:buffer: The buffer to parse.encoding: Is a array of valuesgzipanddeflate.
parseDecompressStream: The function to parse a decompressed stream piping. Receive two parameters:stream: The stream to parse.encoding: Is a array of valuesgzipanddeflate.
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. UsingURLSearchParamsAPI.headers: The object of headers of the request.body: The body of the request. It's aobject.- The
bodyproperty is only available if the request has a body and the method is notGET. - If the request
Content-Typeismultipart/form-dataand contains upload files, thebodyproperty will be contains a file metadata stored with name of the field. The metadata interface isFileMetadata. - If the request
Content-Typeisapplication/xml, thebodyproperty will be contains a object with the XML data following the typeimport('@vulppi/intrest).XMLBody.
- The
cookies: The object of cookies of the request. UsingcookieAPI.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 aobjectcontaining theurlandipproperties.url: The origin URL of the request. It's aURLobject.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,BufferorReadableStream.- The
bodyproperty is only available if the response has a body. - If the response
bodyis aobject, theContent-Typeheader will be set toapplication/jsonif not exists. - If the response
bodyis aBufferor astring, theContent-Typeheader will be set toplain/textif not exists. - If the response
bodyis aReadableStream, theContent-Typeheader will be set toapplication/octet-streamif 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.