Git Product home page Git Product logo

plugin-cloud's Introduction

Payload Cloud Plugin

๐Ÿ“ข Moved to Payload Monorepo ๐Ÿ“ข

This is the official Payload Cloud plugin that connects your Payload instance to the resources that Payload Cloud provides.

File storage

Payload Cloud gives you S3 file storage backed by Cloudflare as a CDN, and this plugin extends Payload so that all of your media will be stored in S3 rather than locally.

Email delivery

Payload Cloud provides an email delivery service out-of-the-box for all Payload Cloud customers. Powered by Resend.

Upload caching

Payload Cloud provides a caching for all upload collections by default through Cloudflare's CDN.

How to use

Add the plugin to your Payload config

yarn add @payloadcms/plugin-cloud

import { payloadCloud } from '@payloadcms/plugin-cloud'
import { buildConfig } from 'payload/config'

export default buildConfig({
  plugins: [payloadCloud()]
  // rest of config
})

NOTE: If your Payload config already has an email with transport, this will take precedence over Payload Cloud's email service.

Optional configuration

If you wish to opt-out of any Payload cloud features, the plugin also accepts options to do so.

payloadCloud({
  storage: false, // Disable file storage
  email: false,   // Disable email delivery
  uploadCaching: false // Disable upload caching
})

Upload Caching Configuration

If you wish to configure upload caching on a per-collection basis, you can do so by passing in a keyed object of collection names. By default, all collections will be cached for 24 hours (86400 seconds). The cache is invalidated when an item is updated or deleted.

payloadCloud({
  uploadCaching: {
    maxAge: 604800, // Override default maxAge for all collections
    collection1Slug: {
      maxAge: 10 // Collection-specific maxAge, takes precedence over others
    },
    collection2Slug: {
      enabled: false // Disable caching for this collection
    }
  }
})

Accessing File Storage from Local Environment

This plugin works off of a specific set of environment variables in order to access your file resources. Here is this list with some prefilled.

PORT=3000
MONGODB_URI=
PAYLOAD_CLOUD=true
PAYLOAD_CLOUD_ENVIRONMENT=prod
PAYLOAD_CLOUD_BUCKET=
PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID=
PAYLOAD_CLOUD_COGNITO_USER_POOL_CLIENT_ID=
PAYLOAD_CLOUD_COGNITO_USER_POOL_ID=
PAYLOAD_CLOUD_PROJECT_ID=
PAYLOAD_CLOUD_COGNITO_PASSWORD=
PAYLOAD_CLOUD_BUCKET_REGION=

PAYLOAD_SECRET=
  • MONGODB_URI is on the the Database tab.
  • PAYLOAD_CLOUD_PROJECT_ID is from Settings -> Billing.
  • PAYLOAD_SECRET is from Settings -> Environment Variables

The remaining values can be seen on your project's File Storage tab. You'll have to match up the values appropriately. We plan on adding the ability to easily copy these values in the near future.

Future enhancements

API CDN

In the future, this plugin will also ship with a way to dynamically cache API requests as well as purge them whenever a resource is updated.

When it executes

This plugin will only execute if the required environment variables set by Payload Cloud are in place. If they are not, the plugin will not execute and your Payload instance will behave as normal.

plugin-cloud's People

Contributors

denolfe avatar jmikrut avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

plugin-cloud's Issues

Document default behavior for uploads (and upload collection configuration)

I think the readme currently implies that files are automatically stored in the cloud (and local storage is disabled):

this plugin extends Payload so that all of your media will be stored in S3 rather than locally.

But it's hard to tell whether this happens automatically or if you still need some amount of configuration in the collection(s) you're using for uploads themselves. E.g. does a media collection still need staticDir, disableLocalStorage, etc?

Media ts โ€” paper-triangles-cms-Wednesday-June-21-2023-09 38 27AM@2x

It'd be great to clarify in this repo's readme (or the main doc website may be even better) what is needed for upload configuration when using Payload Cloud vs. the cloud-storage plug-in vs. default local storage.

Add environmental variable to expose current commit hash

Hi, It would be great to have access to the currently deployed commit hash via env variable, e.g. PAYLOAD_CLOUD_COMMIT.
This way one could display or use it to identify the deployed version when collecting bug reports and the like.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.