feat: builds plugin with azure adapter

This commit is contained in:
James
2022-08-06 14:49:46 -04:00
parent 4e1da749c9
commit 2b7547fbae
28 changed files with 1363 additions and 550 deletions

View File

@@ -1,13 +1,56 @@
import type { CollectionConfig } from 'payload/types'
/* eslint-disable no-console */
import type { CollectionConfig, Field } from 'payload/types'
const urlField: Field = {
name: 'url',
type: 'text',
hooks: {
afterRead: [
({ value }) => {
console.log('hello from hook')
return value
},
],
},
}
export const Media: CollectionConfig = {
slug: 'media',
upload: true,
upload: {
imageSizes: [
{
height: 400,
width: 400,
crop: 'center',
name: 'square',
},
{
width: 900,
height: 450,
crop: 'center',
name: 'sixteenByNineMedium',
},
],
},
fields: [
{
name: 'alt',
label: 'Alt Text',
type: 'text',
},
// The following fields should be able to be merged in to default upload fields
urlField,
{
name: 'sizes',
type: 'group',
fields: [
{
name: 'square',
type: 'group',
fields: [urlField],
},
],
},
],
}

View File

@@ -1,10 +1,8 @@
import { CollectionConfig } from 'payload/types';
import type { CollectionConfig } from 'payload/types'
const Users: CollectionConfig = {
slug: 'users',
auth: {
disableLocalStrategy: true,
},
auth: true,
admin: {
useAsTitle: 'upn',
},
@@ -14,6 +12,6 @@ const Users: CollectionConfig = {
fields: [
// no fields in this demo necessary
],
};
}
export default Users;
export default Users

View File

@@ -1,7 +1,7 @@
import { buildConfig } from 'payload/config'
import path from 'path'
import Users from './collections/Users'
import { cloudStorage } from '../../src/plugin'
import { cloudStorage, azureBlobStorageAdapter } from '../../src'
import { Media } from './collections/Media'
export default buildConfig({
@@ -32,7 +32,13 @@ export default buildConfig({
cloudStorage({
collections: [
{
slug: 'users',
slug: 'media',
adapter: azureBlobStorageAdapter({
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
containerName: process.env.AZURE_STORAGE_CONTAINER_NAME,
allowContainerCreate: process.env.AZURE_STORAGE_ALLOW_CONTAINER_CREATE === 'true',
baseURL: process.env.AZURE_STORAGE_ACCOUNT_BASEURL,
}),
},
],
}),