generated from autonomic-cooperative/astro-payload-template
Compare commits
6 Commits
7dbc81c5b2
...
0bb0644b55
Author | SHA1 | Date | |
---|---|---|---|
|
0bb0644b55 | ||
|
b85c62f3fc | ||
910f943a2d | |||
|
10cb01964b | ||
|
91073bd498 | ||
|
cc0a5cb1c5 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,4 +3,4 @@ data
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
payload-types.ts
|
#payload-types.ts
|
@ -6,7 +6,7 @@
|
|||||||
"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 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",
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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']
|
||||||
}
|
}
|
||||||
})
|
}) */
|
||||||
}
|
}
|
@ -7,7 +7,8 @@
|
|||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*", "./dist/*", "./dist/src/*"]
|
"@/*": ["./src/*", "./dist/*", "./dist/src/*"],
|
||||||
|
"@/types/*": ["./types/*"]
|
||||||
},
|
},
|
||||||
"jsx": "react"
|
"jsx": "react"
|
||||||
},
|
},
|
||||||
|
66
payload/types/payload-types.ts
Normal file
66
payload/types/payload-types.ts
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user