Skip to content

A small caching proxy for Contentful's CDA written with and for micro.

License

Notifications You must be signed in to change notification settings

felixjung/contentful-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Small authentication and caching proxy service for Contentful's Content Delivery API (CDA) written for and using Zeit.co's micro. Useful for front-end's connecting to Contentful and for people who have problems with their request cap.

Installation

This project uses yarn, so run the following from the terminal:

$ yarn

You can also install via npm by running

$ npm install

Usage

Because micro requires Node.js 6.0.0 or above, the same is true for this project.

Configuration

Copy config.json.example to config.json and specify the required options listed below.

Option Note Description
accessToken String required The space's access token for the production CDA.
previewToken String optional The space's access token for the CPA.
preview Boolean optional Should the CPA be proxied? If set to true, make sure the previewToken is specified.
spaceId String optional The ID of you space. If specified, you won't have to set /spaces/{spaceId} in your requests.
secure Boolean optional Should the proxy use HTTPS and verify Contentful's SSL certificate.

Start

Running

$ yarn start

from the terminal will start the server on port 3000 listening at localhost.

You can also start the proxy by installing micro globally and running

$ micro

with any of micro's standard options.

Caching

The proxy will cache any responses from Contentful using the full URL including query params as key. Cached values never expire and are used for both, the response body and headers, when responding to subsequent requests. To clear the cache, for example using Contentful's post-publishing hooks, send a DELETE request to the service.

About

A small caching proxy for Contentful's CDA written with and for micro.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published