11 Commits

Author SHA1 Message Date
6ca3ab875b Bump
All checks were successful
continuous-integration/drone Build is passing
2024-06-04 15:12:29 +02:00
e9fb68ec9f Fix typo in build script
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-04 10:02:40 +02:00
f37a1719b7 Update payload to 2.18.3
Some checks failed
continuous-integration/drone/push Build is failing
2024-05-27 11:24:42 +02:00
d62e7d788e Restore dev, build & gen:types scripts
All checks were successful
continuous-integration/drone/push Build is passing
2024-05-25 08:18:33 +02:00
8fdfb2fbe4 Check if dev script is stopping build (??)
All checks were successful
continuous-integration/drone/push Build is passing
2024-05-24 09:10:43 +02:00
0bb0644b55 Move payload types to within payload
All checks were successful
continuous-integration/drone/push Build is passing
2024-05-22 09:21:31 +02:00
b85c62f3fc Try to make build work
Some checks failed
continuous-integration/drone/push Build is failing
2024-05-22 09:13:09 +02:00
3wc
910f943a2d Tweak Drone pipeline to trigger build
Some checks reported errors
continuous-integration/drone/push Build was killed
2024-05-21 18:15:14 -03:00
10cb01964b Change order of payload build steps
Some checks failed
continuous-integration/drone/push Build is failing
2024-05-21 12:52:07 +02:00
91073bd498 Generate types before building payload
Some checks failed
continuous-integration/drone/push Build is failing
2024-05-21 12:22:55 +02:00
cc0a5cb1c5 Add types dir to payload tsconfig
Some checks failed
continuous-integration/drone/push Build is failing
2024-05-21 12:14:53 +02:00
14 changed files with 2761 additions and 1723 deletions

2
.gitignore vendored
View File

@ -3,4 +3,4 @@ data
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
payload-types.ts #payload-types.ts

View File

@ -11,3 +11,4 @@
"dev:nobuild": "docker compose up" "dev:nobuild": "docker compose up"
} }
} }

66
payload-types.ts Normal file
View File

@ -0,0 +1,66 @@
/* tslint:disable */
/* eslint-disable */
/**
* This file was automatically generated by Payload.
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,
* and re-run `payload generate:types` to regenerate this file.
*/
export interface Config {
collections: {
posts: Post;
users: User;
authors: Author;
media: Media;
};
globals: {};
}
export interface Post {
id: string;
title: string;
summary?: string;
publishedDate?: string;
thumbnail: string | Media;
content?: {
[k: string]: unknown;
}[];
author?: string | Author;
status: 'draft' | 'published' | 'archived';
updatedAt: string;
createdAt: string;
}
export interface Media {
id: string;
alt: string;
updatedAt: string;
createdAt: string;
url?: string;
filename?: string;
mimeType?: string;
filesize?: number;
width?: number;
height?: number;
}
export interface Author {
id: string;
avatar: string | Media;
name: string;
bio?: string;
user?: string | User;
updatedAt: string;
createdAt: string;
}
export interface User {
id: string;
roles: ('ssg' | 'admin' | 'editor' | 'user')[];
updatedAt: string;
createdAt: string;
email: string;
resetPasswordToken?: string;
resetPasswordExpiration?: string;
salt?: string;
hash?: string;
loginAttempts?: number;
lockUntil?: string;
password?: string;
}

View File

@ -6,18 +6,22 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon", "dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts node -r tsconfig-paths/register node_modules/payload/dist/bin/index.js build", "build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts node -r tsconfig-paths/register node_modules/payload/dist/bin/index.js build ",
"build:server": "tsc", "build:server": "tsc",
"build": "yarn build:payload && yarn build:server", "build": "yarn generate:types && yarn build:payload && yarn build:server",
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js node -r tsconfig-paths/register dist/server.js", "serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js node -r tsconfig-paths/register dist/server.js",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts node -r tsconfig-paths/register node_modules/payload/dist/bin/index.js generate:types", "generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts node -r tsconfig-paths/register node_modules/payload/dist/bin/index.js generate:types",
"generate:types:listen": "nodemon --watch src --ext ts --exec 'npm run generate:types'" "generate:types:listen": "nodemon --watch src --ext ts --exec 'npm run generate:types'"
}, },
"dependencies": { "dependencies": {
"@payloadcms/bundler-webpack": "^1.0.6",
"@payloadcms/db-mongodb": "^1.5.1",
"@payloadcms/plugin-cloud": "^3.0.1",
"@payloadcms/richtext-slate": "^1.5.2",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"express": "^4.17.1", "express": "^4.17.1",
"payload": "^1.15.6", "payload": "^2.18.3",
"tsconfig-paths": "^4.2.0" "tsconfig-paths": "^4.2.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,5 +1,5 @@
import { Access, FieldAccess } from "payload/types"; import { Access, FieldAccess } from "payload/types";
import { User } from "../payload-types"; import { User } from "@/types/payload-types";
export const isAdmin: Access<any, User> = ({ req: { user } }) => { export const isAdmin: Access<any, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an admin role // Return true or false based on if the user has an admin role

View File

@ -1,5 +1,5 @@
import { Access, FieldAccess } from "payload/types"; import { Access, FieldAccess } from "payload/types";
import { User } from "../payload-types"; import { User } from "@/types/payload-types";
export const isEditor: Access<any, User> = ({ req: { user } }) => { export const isEditor: Access<any, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an editor role // Return true or false based on if the user has an editor role

View File

@ -1,5 +1,5 @@
import { Access, FieldAccess } from "payload/types"; import { Access, FieldAccess } from "payload/types";
import { User } from "../payload-types"; import { User } from "@/types/payload-types";
export const isSSG: Access<any, User> = ({ req: { user } }) => { export const isSSG: Access<any, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an ssg or admin role // Return true or false based on if the user has an ssg or admin role

View File

@ -1,5 +1,5 @@
import { Access, FieldAccess } from "payload/types"; import { Access, FieldAccess } from "payload/types";
import { User } from "../payload-types"; import { User } from "@/types/payload-types";
export const isUser: Access<any, User> = ({ req: { user } }) => { export const isUser: Access<any, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an ssg or admin role // Return true or false based on if the user has an ssg or admin role

View File

@ -3,6 +3,7 @@ import { isAdmin } from "@/access/isAdmin";
import { isEditor } from "@/access/isEditor"; import { isEditor } from "@/access/isEditor";
import { isSSG } from "@/access/isSSG"; import { isSSG } from "@/access/isSSG";
import { isUser } from "@/access/isUser"; import { isUser } from "@/access/isUser";
import { slateEditor } from '@payloadcms/richtext-slate'
const Posts: CollectionConfig = { const Posts: CollectionConfig = {
slug: "posts", slug: "posts",
@ -68,11 +69,12 @@ const Posts: CollectionConfig = {
required: true, required: true,
}, },
{ {
name: "content", name: 'content',
type: "richText", type: 'richText',
editor: slateEditor({
admin: { admin: {
elements: ["h2", "h3", "h4", "link", "ol", "ul", "upload", "blockquote", "indent"], elements: ["h2", "h3", "h4", "link", "ol", "ul", "upload", "blockquote", "indent"],
leaves: ["bold", "italic", "underline"], leaves: ["bold", "italic", "underline", "strikethrough"],
upload: { upload: {
collections: { collections: {
media: { media: {
@ -88,6 +90,7 @@ const Posts: CollectionConfig = {
}, },
}, },
}, },
})
}, },
{ {
name: "author", name: "author",

View File

@ -5,10 +5,16 @@ import Users from "@/collections/Users";
import Authors from "./collections/Authors"; import Authors from "./collections/Authors";
import Media from "@/collections/Media"; import Media from "@/collections/Media";
import { payloadCloud } from '@payloadcms/plugin-cloud'
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { webpackBundler } from '@payloadcms/bundler-webpack'
import { slateEditor } from '@payloadcms/richtext-slate'
export default buildConfig({ export default buildConfig({
serverURL: process.env.PAYLOAD_URL, serverURL: process.env.PAYLOAD_URL,
admin: { admin: {
user: Users.slug, user: Users.slug,
bundler: webpackBundler(),
webpack: (config) => ({ webpack: (config) => ({
...config, ...config,
resolve: { resolve: {
@ -24,4 +30,9 @@ export default buildConfig({
typescript: { typescript: {
outputFile: path.resolve("../", "payload-types.ts"), outputFile: path.resolve("../", "payload-types.ts"),
}, },
plugins: [payloadCloud()],
editor: slateEditor({}),
db: mongooseAdapter({
url: process.env.MONGODB_URI,
}),
}); });

View File

@ -1,15 +1,17 @@
import { Payload } from "payload"; import { Payload } from "payload";
import { User } from "./payload-types"; import { User } from "@/types/payload-types";
export const seed = async (payload: Payload): Promise<void> => { export const seed = async (payload: Payload): Promise<void> => {
// Local API methods skip all access control by default // Local API methods skip all access control by default
// so we can easily create an admin user directly in init // so we can easily create an admin user directly in init
await payload.create<User>({
/* Disable to prevent mistakes */
/* await payload.create<User>({
collection: 'users', collection: 'users',
data: { data: {
email: 'astro@ssg.js', email: 'astro@ssg.js',
password: 'password', password: 'password',
roles: ['ssg'] roles: ['ssg']
} }
}) }) */
} }

View File

@ -10,7 +10,7 @@ app.get("/", (_, res) => {
payload.init({ payload.init({
secret: process.env.PAYLOAD_SECRET, secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI, //mongoURL: process.env.MONGODB_URI,
express: app, express: app,
onInit: () => { onInit: () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`); payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);

View File

@ -7,7 +7,8 @@
"skipLibCheck": true, "skipLibCheck": true,
"outDir": "./dist", "outDir": "./dist",
"paths": { "paths": {
"@/*": ["./src/*", "./dist/*", "./dist/src/*"] "@/*": ["./src/*", "./dist/*", "./dist/src/*"],
"@/types/*": ["../*"]
}, },
"jsx": "react" "jsx": "react"
}, },

File diff suppressed because it is too large Load Diff