1.1.0 • Published 6 years ago

@cachepile/middleware v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

Logo

Cachepile Express Middleware version License Build Status

CachePile Express Middleware

Install

npm install --production --save @cachepile/middleware

API

lib()

Middleware usage

const express = require('express')
const middleware = require('@cachepile/middleware')

const app = express()
app.use(middleware())
app.listen(3000, () =>  console.log(`Cachepile listening on 3000`))

Configs

You can pass in an options object into the middleware initialization. Here are the options: Key | Description | Default Value ------------ | ---------------------------------------------------- | -------------- headerPrefix | specify the prefix for the headers | cp redis | redis node is used under the hood. See a list of options here

Client usage

# call api to cache through the proxy
curl -i -H "cp-target-port: 443" -H "cp-ttl: 10" -H "CP-TARGET-HOST: reqres.in" -H "CP-TARGET-PROTO: https"  localhost:3000/api/users

Headers

HeaderDescriptionDefault Value
CP-FORCEForce request to call through to specified end pointfalse
CP-TARGET-HOSThost of endpoint to cacherequested host
CP-TARGET-PORTport of endpoint to cacherequested port
CP-TARGET-PROTOprotocol for endpoint to cachehttp
CP-TTLtime in seconds to cache response1
CP-WAITif set to false(default) the proxy will wait for the response from the server before responding to the client request. Otherwise, it will return 201 and fetch the request in the background.false

License: ISC • Copyright: ahmadnassri.com • Github: @ahmadnassri • Twitter: @ahmadnassri

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago