0.1.4 • Published 5 years ago

nestjs-prismic v0.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

nestjs-prismic

npm

This library contains a module for Nest.js to access the Prismic.io API. It is intended to work in pair with the Predicates from the official prismic-javascript library.

Get started

yarn add -E nestjs-prismic

Usage

1. Import the module

import { Module } from '@nestjs/common';
import { PrismicModule } from 'nestjs-prismic';

@Module({
  imports: [
    PrismicModule.register({
      url: 'your prismic api v2 url',
      webhookSecret: 'webhook secret used to update the current master ref'
    })
  ],
  ...
})
export class MyModule {}

2. Use the fetchDataByPredicate() function to query data

Use the included PrismicService together with Predicates to query your repository. The library is currently only able to access the latest data on your masterRef.

Data will be cached until the masterRef is updated via webhook.

3. Use custom Controllers to prepare and serve your data

Now the data from the CMS can be used by your app. For example, provide endpoints for a frontend application to access this data.

4. Connect the webhook

Register a webhook in your prismic repository to your Nest-app's /prismic/masterRef endpoint to automatically update the masterRef and clear the included cache.