Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/telus/cachepile-middleware
https://github.com/telus/cachepile-middleware
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/telus/cachepile-middleware
- Owner: telus
- License: isc
- Created: 2018-08-17T21:27:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T07:46:34.000Z (10 months ago)
- Last Synced: 2024-01-11T12:04:54.489Z (10 months ago)
- Language: JavaScript
- Size: 379 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![Logo](https://github.com/cachepile/brand/blob/master/logo.svg)
# Cachepile Express Middleware [![version][npm-version]][npm-url] [![License][license-image]][license-url] [![Build Status][travis-image]][travis-url]
> [CachePile][cachepile] Express Middleware
## Install
```bash
npm install --production --save @cachepile/middleware
```## API
### lib()
#### Middleware usage
```js
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](https://github.com/NodeRedis/node_redis#rediscreateclient)#### Client usage
```bash
# 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
Header | Description | Default Value
--------------- | ---------------------------------------------------- | --------------
CP-FORCE | Force request to call through to specified end point | false
CP-TARGET-HOST | host of endpoint to cache | requested host
CP-TARGET-PORT | port of endpoint to cache | requested port
CP-TARGET-PROTO | protocol for endpoint to cache | http
CP-TTL | time in seconds to cache response | 1
CP-WAIT | if 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][license-url] •
> Copyright: [ahmadnassri.com](https://www.ahmadnassri.com) •
> Github: [@ahmadnassri](https://github.com/ahmadnassri) •
> Twitter: [@ahmadnassri](https://twitter.com/ahmadnassri)[license-url]: http://choosealicense.com/licenses/isc/
[license-image]: https://img.shields.io/github/license/cachepile/middleware.svg?style=flat-square
[travis-url]: https://travis-ci.org/cachepile/middleware
[travis-image]: https://img.shields.io/travis/cachepile/middleware.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/@cachepile/middleware
[npm-version]: https://img.shields.io/npm/v/@cachepile/middleware.svg?style=flat-square
[cachepile]: https://cachepile.github.io