create-payload-app 0.3.34 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/lib/create-project.js +33 -87
- package/dist/lib/create-project.test.js +37 -52
- package/dist/lib/templates.js +38 -71
- package/dist/lib/write-env-file.js +20 -15
- package/dist/main.js +14 -2
- package/dist/utils/messages.js +2 -1
- package/package.json +1 -1
- package/dist/lib/common-files/Dockerfile.template +0 -26
- package/dist/lib/common-files/README.template.md +0 -19
- package/dist/lib/common-files/docker-compose.template.yml +0 -35
- package/dist/lib/common-files/gitignore.template +0 -166
- package/dist/lib/common-files/nodemon.json +0 -4
- package/dist/lib/common-files/package.template.json +0 -30
- package/dist/lib/common-files/tsconfig.json +0 -34
- package/dist/lib/write-common-files.js +0 -124
- package/dist/templates/blank/src/collections/Examples.ts +0 -17
- package/dist/templates/blank/src/collections/Users.ts +0 -15
- package/dist/templates/blank/src/payload.config.ts +0 -22
- package/dist/templates/blank/src/server.ts +0 -28
- package/dist/templates/blog/src/collections/Categories.ts +0 -20
- package/dist/templates/blog/src/collections/Media.ts +0 -28
- package/dist/templates/blog/src/collections/Posts.ts +0 -62
- package/dist/templates/blog/src/collections/Tags.ts +0 -20
- package/dist/templates/blog/src/collections/Users.ts +0 -18
- package/dist/templates/blog/src/payload.config.ts +0 -21
- package/dist/templates/blog/src/server.ts +0 -28
- package/dist/templates/todo/src/collections/TodoLists.ts +0 -38
- package/dist/templates/todo/src/collections/Users.ts +0 -15
- package/dist/templates/todo/src/payload.config.ts +0 -18
- package/dist/templates/todo/src/server.ts +0 -28
@@ -1,166 +0,0 @@
|
|
1
|
-
### Node ###
|
2
|
-
# Logs
|
3
|
-
logs
|
4
|
-
*.log
|
5
|
-
npm-debug.log*
|
6
|
-
yarn-debug.log*
|
7
|
-
yarn-error.log*
|
8
|
-
lerna-debug.log*
|
9
|
-
.pnpm-debug.log*
|
10
|
-
|
11
|
-
# Diagnostic reports (https://nodejs.org/api/report.html)
|
12
|
-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
13
|
-
|
14
|
-
# Runtime data
|
15
|
-
pids
|
16
|
-
*.pid
|
17
|
-
*.seed
|
18
|
-
*.pid.lock
|
19
|
-
|
20
|
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
21
|
-
lib-cov
|
22
|
-
|
23
|
-
# Coverage directory used by tools like istanbul
|
24
|
-
coverage
|
25
|
-
*.lcov
|
26
|
-
|
27
|
-
# nyc test coverage
|
28
|
-
.nyc_output
|
29
|
-
|
30
|
-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
31
|
-
.grunt
|
32
|
-
|
33
|
-
# Bower dependency directory (https://bower.io/)
|
34
|
-
bower_components
|
35
|
-
|
36
|
-
# node-waf configuration
|
37
|
-
.lock-wscript
|
38
|
-
|
39
|
-
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
40
|
-
build/Release
|
41
|
-
|
42
|
-
# Dependency directories
|
43
|
-
node_modules/
|
44
|
-
jspm_packages/
|
45
|
-
|
46
|
-
# Snowpack dependency directory (https://snowpack.dev/)
|
47
|
-
web_modules/
|
48
|
-
|
49
|
-
# TypeScript cache
|
50
|
-
*.tsbuildinfo
|
51
|
-
|
52
|
-
# Optional npm cache directory
|
53
|
-
.npm
|
54
|
-
|
55
|
-
# Optional eslint cache
|
56
|
-
.eslintcache
|
57
|
-
|
58
|
-
# Optional stylelint cache
|
59
|
-
.stylelintcache
|
60
|
-
|
61
|
-
# Microbundle cache
|
62
|
-
.rpt2_cache/
|
63
|
-
.rts2_cache_cjs/
|
64
|
-
.rts2_cache_es/
|
65
|
-
.rts2_cache_umd/
|
66
|
-
|
67
|
-
# Optional REPL history
|
68
|
-
.node_repl_history
|
69
|
-
|
70
|
-
# Output of 'npm pack'
|
71
|
-
*.tgz
|
72
|
-
|
73
|
-
# Yarn Integrity file
|
74
|
-
.yarn-integrity
|
75
|
-
|
76
|
-
# dotenv environment variable files
|
77
|
-
.env
|
78
|
-
.env.development.local
|
79
|
-
.env.test.local
|
80
|
-
.env.production.local
|
81
|
-
.env.local
|
82
|
-
|
83
|
-
# parcel-bundler cache (https://parceljs.org/)
|
84
|
-
.cache
|
85
|
-
.parcel-cache
|
86
|
-
|
87
|
-
# Next.js build output
|
88
|
-
.next
|
89
|
-
out
|
90
|
-
|
91
|
-
# Nuxt.js build / generate output
|
92
|
-
.nuxt
|
93
|
-
dist
|
94
|
-
|
95
|
-
# Gatsby files
|
96
|
-
.cache/
|
97
|
-
# Comment in the public line in if your project uses Gatsby and not Next.js
|
98
|
-
# https://nextjs.org/blog/next-9-1#public-directory-support
|
99
|
-
# public
|
100
|
-
|
101
|
-
# vuepress build output
|
102
|
-
.vuepress/dist
|
103
|
-
|
104
|
-
# vuepress v2.x temp and cache directory
|
105
|
-
.temp
|
106
|
-
|
107
|
-
# Docusaurus cache and generated files
|
108
|
-
.docusaurus
|
109
|
-
|
110
|
-
# Serverless directories
|
111
|
-
.serverless/
|
112
|
-
|
113
|
-
# FuseBox cache
|
114
|
-
.fusebox/
|
115
|
-
|
116
|
-
# DynamoDB Local files
|
117
|
-
.dynamodb/
|
118
|
-
|
119
|
-
# TernJS port file
|
120
|
-
.tern-port
|
121
|
-
|
122
|
-
# Stores VSCode versions used for testing VSCode extensions
|
123
|
-
.vscode-test
|
124
|
-
|
125
|
-
# yarn v2
|
126
|
-
.yarn/cache
|
127
|
-
.yarn/unplugged
|
128
|
-
.yarn/build-state.yml
|
129
|
-
.yarn/install-state.gz
|
130
|
-
.pnp.*
|
131
|
-
|
132
|
-
### Node Patch ###
|
133
|
-
# Serverless Webpack directories
|
134
|
-
.webpack/
|
135
|
-
|
136
|
-
# Optional stylelint cache
|
137
|
-
|
138
|
-
# SvelteKit build / generate output
|
139
|
-
.svelte-kit
|
140
|
-
|
141
|
-
### VisualStudioCode ###
|
142
|
-
.vscode/*
|
143
|
-
!.vscode/settings.json
|
144
|
-
!.vscode/tasks.json
|
145
|
-
!.vscode/launch.json
|
146
|
-
!.vscode/extensions.json
|
147
|
-
!.vscode/*.code-snippets
|
148
|
-
|
149
|
-
# Local History for Visual Studio Code
|
150
|
-
.history/
|
151
|
-
|
152
|
-
# Built Visual Studio Code Extensions
|
153
|
-
*.vsix
|
154
|
-
|
155
|
-
### VisualStudioCode Patch ###
|
156
|
-
# Ignore all local history of files
|
157
|
-
.history
|
158
|
-
.ionide
|
159
|
-
|
160
|
-
# Support for Project snippet scope
|
161
|
-
.vscode/*.code-snippets
|
162
|
-
|
163
|
-
# Ignore code-workspaces
|
164
|
-
*.code-workspace
|
165
|
-
|
166
|
-
# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode
|
@@ -1,30 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "{{projectName}}",
|
3
|
-
"description": "Payload project created from {{templateName}} template",
|
4
|
-
"version": "1.0.0",
|
5
|
-
"main": "dist/server.js",
|
6
|
-
"license": "MIT",
|
7
|
-
"scripts": {
|
8
|
-
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
|
9
|
-
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
|
10
|
-
"build:server": "tsc",
|
11
|
-
"build": "{{runCommand}} copyfiles && {{runCommand}} build:payload && {{runCommand}} build:server",
|
12
|
-
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
|
13
|
-
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
|
14
|
-
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
|
15
|
-
"generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
|
16
|
-
},
|
17
|
-
"dependencies": {
|
18
|
-
"payload": "1.1.17",
|
19
|
-
"dotenv": "^8.2.0",
|
20
|
-
"express": "^4.17.1",
|
21
|
-
"cross-env": "^7.0.3"
|
22
|
-
},
|
23
|
-
"devDependencies": {
|
24
|
-
"@types/express": "^4.17.9",
|
25
|
-
"nodemon": "^2.0.6",
|
26
|
-
"ts-node": "^9.1.1",
|
27
|
-
"copyfiles": "^2.4.1",
|
28
|
-
"typescript": "^4.8.4"
|
29
|
-
}
|
30
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "es5",
|
4
|
-
"lib": [
|
5
|
-
"dom",
|
6
|
-
"dom.iterable",
|
7
|
-
"esnext"
|
8
|
-
],
|
9
|
-
"allowJs": true,
|
10
|
-
"strict": false,
|
11
|
-
"esModuleInterop": true,
|
12
|
-
"skipLibCheck": true,
|
13
|
-
"outDir": "./dist",
|
14
|
-
"rootDir": "./src",
|
15
|
-
"jsx": "react",
|
16
|
-
"paths": {
|
17
|
-
"payload/generated-types": [
|
18
|
-
"./src/payload-types.ts",
|
19
|
-
],
|
20
|
-
}
|
21
|
-
},
|
22
|
-
"include": [
|
23
|
-
"src"
|
24
|
-
],
|
25
|
-
"exclude": [
|
26
|
-
"node_modules",
|
27
|
-
"dist",
|
28
|
-
"build",
|
29
|
-
],
|
30
|
-
"ts-node": {
|
31
|
-
"transpileOnly": true,
|
32
|
-
"swc": true,
|
33
|
-
}
|
34
|
-
}
|
@@ -1,124 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
-
function step(op) {
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
17
|
-
while (_) try {
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
-
switch (op[0]) {
|
21
|
-
case 0: case 1: t = op; break;
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
-
default:
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
-
if (t[2]) _.ops.pop();
|
31
|
-
_.trys.pop(); continue;
|
32
|
-
}
|
33
|
-
op = body.call(thisArg, _);
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
-
}
|
37
|
-
};
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
40
|
-
};
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
-
exports.writeCommonFiles = void 0;
|
43
|
-
var path_1 = __importDefault(require("path"));
|
44
|
-
var fs_extra_1 = __importDefault(require("fs-extra"));
|
45
|
-
var handlebars_1 = __importDefault(require("handlebars"));
|
46
|
-
function writeCommonFiles(projectDir, template, packageManager) {
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
48
|
-
var commonFilesDir, gi, giDest, packageJsonTemplate, packageJson, nodemon, nodemonDest, readmeTemplate, readme, tsconfig, tsconfigDest, dockerComposeTemplate, dockerCompose, dockerfileTemplate, dockerfile;
|
49
|
-
return __generator(this, function (_a) {
|
50
|
-
switch (_a.label) {
|
51
|
-
case 0:
|
52
|
-
commonFilesDir = path_1.default.resolve(__dirname, 'common-files');
|
53
|
-
gi = path_1.default.resolve(commonFilesDir, 'gitignore.template');
|
54
|
-
giDest = path_1.default.resolve(projectDir, '.gitignore');
|
55
|
-
return [4 /*yield*/, fs_extra_1.default.copy(gi, giDest)
|
56
|
-
// package.json
|
57
|
-
];
|
58
|
-
case 1:
|
59
|
-
_a.sent();
|
60
|
-
return [4 /*yield*/, fs_extra_1.default.readFile(path_1.default.resolve(commonFilesDir, 'package.template.json'), 'utf8')];
|
61
|
-
case 2:
|
62
|
-
packageJsonTemplate = _a.sent();
|
63
|
-
packageJson = handlebars_1.default.compile(packageJsonTemplate)({
|
64
|
-
projectName: path_1.default.basename(projectDir),
|
65
|
-
templateName: template.name,
|
66
|
-
runCommand: packageManager === 'yarn' ? 'yarn' : 'npm run',
|
67
|
-
});
|
68
|
-
return [4 /*yield*/, fs_extra_1.default.writeFile(path_1.default.resolve(projectDir, 'package.json'), packageJson)
|
69
|
-
// nodemon.json
|
70
|
-
];
|
71
|
-
case 3:
|
72
|
-
_a.sent();
|
73
|
-
nodemon = path_1.default.resolve(commonFilesDir, 'nodemon.json');
|
74
|
-
nodemonDest = path_1.default.resolve(projectDir, 'nodemon.json');
|
75
|
-
return [4 /*yield*/, fs_extra_1.default.copy(nodemon, nodemonDest)
|
76
|
-
// README.md
|
77
|
-
];
|
78
|
-
case 4:
|
79
|
-
_a.sent();
|
80
|
-
return [4 /*yield*/, fs_extra_1.default.readFile(path_1.default.resolve(commonFilesDir, 'README.template.md'), 'utf8')];
|
81
|
-
case 5:
|
82
|
-
readmeTemplate = _a.sent();
|
83
|
-
readme = handlebars_1.default.compile(readmeTemplate)({
|
84
|
-
projectName: path_1.default.basename(projectDir),
|
85
|
-
templateName: template.name,
|
86
|
-
});
|
87
|
-
return [4 /*yield*/, fs_extra_1.default.writeFile(path_1.default.resolve(projectDir, 'README.md'), readme)
|
88
|
-
// tsconfig.json
|
89
|
-
];
|
90
|
-
case 6:
|
91
|
-
_a.sent();
|
92
|
-
tsconfig = path_1.default.resolve(commonFilesDir, 'tsconfig.json');
|
93
|
-
tsconfigDest = path_1.default.resolve(projectDir, 'tsconfig.json');
|
94
|
-
return [4 /*yield*/, fs_extra_1.default.copy(tsconfig, tsconfigDest)
|
95
|
-
// docker-compose.yml
|
96
|
-
];
|
97
|
-
case 7:
|
98
|
-
_a.sent();
|
99
|
-
return [4 /*yield*/, fs_extra_1.default.readFile(path_1.default.resolve(commonFilesDir, 'docker-compose.template.yml'), 'utf8')];
|
100
|
-
case 8:
|
101
|
-
dockerComposeTemplate = _a.sent();
|
102
|
-
dockerCompose = handlebars_1.default.compile(dockerComposeTemplate)(packageManager === 'yarn'
|
103
|
-
? { installCmd: 'yarn install', devCmd: 'yarn dev' }
|
104
|
-
: { installCmd: 'npm install', devCmd: 'npm run dev' });
|
105
|
-
return [4 /*yield*/, fs_extra_1.default.writeFile(path_1.default.resolve(projectDir, 'docker-compose.yml'), dockerCompose)
|
106
|
-
// Dockerfile
|
107
|
-
];
|
108
|
-
case 9:
|
109
|
-
_a.sent();
|
110
|
-
return [4 /*yield*/, fs_extra_1.default.readFile(path_1.default.resolve(commonFilesDir, 'Dockerfile.template'), 'utf8')];
|
111
|
-
case 10:
|
112
|
-
dockerfileTemplate = _a.sent();
|
113
|
-
dockerfile = handlebars_1.default.compile(dockerfileTemplate)(packageManager === 'yarn'
|
114
|
-
? { installCmd: 'yarn install', buildCmd: 'yarn build' }
|
115
|
-
: { installCmd: 'npm install', buildCmd: 'npm run build' });
|
116
|
-
return [4 /*yield*/, fs_extra_1.default.writeFile(path_1.default.resolve(projectDir, 'Dockerfile'), dockerfile)];
|
117
|
-
case 11:
|
118
|
-
_a.sent();
|
119
|
-
return [2 /*return*/];
|
120
|
-
}
|
121
|
-
});
|
122
|
-
});
|
123
|
-
}
|
124
|
-
exports.writeCommonFiles = writeCommonFiles;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { CollectionConfig } from 'payload/types';
|
2
|
-
|
3
|
-
// Example Collection - For reference only, this must be added to payload.config.ts to be used.
|
4
|
-
const Examples: CollectionConfig = {
|
5
|
-
slug: 'examples',
|
6
|
-
admin: {
|
7
|
-
useAsTitle: 'someField',
|
8
|
-
},
|
9
|
-
fields: [
|
10
|
-
{
|
11
|
-
name: 'someField',
|
12
|
-
type: 'text',
|
13
|
-
},
|
14
|
-
],
|
15
|
-
}
|
16
|
-
|
17
|
-
export default Examples;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { CollectionConfig } from 'payload/types';
|
2
|
-
|
3
|
-
const Users: CollectionConfig = {
|
4
|
-
slug: 'users',
|
5
|
-
auth: true,
|
6
|
-
admin: {
|
7
|
-
useAsTitle: 'email',
|
8
|
-
},
|
9
|
-
fields: [
|
10
|
-
// Email added by default
|
11
|
-
// Add more fields as needed
|
12
|
-
],
|
13
|
-
};
|
14
|
-
|
15
|
-
export default Users;
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { buildConfig } from 'payload/config';
|
2
|
-
import path from 'path';
|
3
|
-
// import Examples from './collections/Examples';
|
4
|
-
import Users from './collections/Users';
|
5
|
-
|
6
|
-
export default buildConfig({
|
7
|
-
serverURL: 'http://localhost:3000',
|
8
|
-
admin: {
|
9
|
-
user: Users.slug,
|
10
|
-
},
|
11
|
-
collections: [
|
12
|
-
Users,
|
13
|
-
// Add Collections here
|
14
|
-
// Examples,
|
15
|
-
],
|
16
|
-
typescript: {
|
17
|
-
outputFile: path.resolve(__dirname, 'payload-types.ts'),
|
18
|
-
},
|
19
|
-
graphQL: {
|
20
|
-
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
|
21
|
-
},
|
22
|
-
})
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import express from 'express';
|
2
|
-
import payload from 'payload';
|
3
|
-
|
4
|
-
require('dotenv').config();
|
5
|
-
const app = express();
|
6
|
-
|
7
|
-
// Redirect root to Admin panel
|
8
|
-
app.get('/', (_, res) => {
|
9
|
-
res.redirect('/admin');
|
10
|
-
});
|
11
|
-
|
12
|
-
const start = async () => {
|
13
|
-
// Initialize Payload
|
14
|
-
await payload.init({
|
15
|
-
secret: process.env.PAYLOAD_SECRET,
|
16
|
-
mongoURL: process.env.MONGODB_URI,
|
17
|
-
express: app,
|
18
|
-
onInit: async () => {
|
19
|
-
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
20
|
-
},
|
21
|
-
})
|
22
|
-
|
23
|
-
// Add your own express routes here
|
24
|
-
|
25
|
-
app.listen(3000);
|
26
|
-
}
|
27
|
-
|
28
|
-
start();
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { CollectionConfig } from 'payload/types';
|
2
|
-
|
3
|
-
const Categories: CollectionConfig = {
|
4
|
-
slug: 'categories',
|
5
|
-
admin: {
|
6
|
-
useAsTitle: 'name',
|
7
|
-
},
|
8
|
-
access: {
|
9
|
-
read: () => true,
|
10
|
-
},
|
11
|
-
fields: [
|
12
|
-
{
|
13
|
-
name: 'name',
|
14
|
-
type: 'text',
|
15
|
-
},
|
16
|
-
],
|
17
|
-
timestamps: false,
|
18
|
-
}
|
19
|
-
|
20
|
-
export default Categories;
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import path from 'path';
|
2
|
-
import type { CollectionConfig } from 'payload/types';
|
3
|
-
|
4
|
-
const Media: CollectionConfig = {
|
5
|
-
slug: 'media',
|
6
|
-
upload: {
|
7
|
-
staticDir: path.resolve(__dirname, '../../media'),
|
8
|
-
// Specify the size name that you'd like to use as admin thumbnail
|
9
|
-
adminThumbnail: 'thumbnail',
|
10
|
-
imageSizes: [
|
11
|
-
{
|
12
|
-
height: 400,
|
13
|
-
width: 400,
|
14
|
-
crop: 'center',
|
15
|
-
name: 'thumbnail',
|
16
|
-
},
|
17
|
-
{
|
18
|
-
width: 900,
|
19
|
-
height: 450,
|
20
|
-
crop: 'center',
|
21
|
-
name: 'sixteenByNineMedium',
|
22
|
-
},
|
23
|
-
],
|
24
|
-
},
|
25
|
-
fields: [],
|
26
|
-
};
|
27
|
-
|
28
|
-
export default Media;
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import { CollectionConfig } from 'payload/types';
|
2
|
-
|
3
|
-
const Posts: CollectionConfig = {
|
4
|
-
slug: 'posts',
|
5
|
-
admin: {
|
6
|
-
defaultColumns: ['title', 'author', 'category', 'tags', 'status'],
|
7
|
-
useAsTitle: 'title',
|
8
|
-
},
|
9
|
-
access: {
|
10
|
-
read: () => true,
|
11
|
-
},
|
12
|
-
fields: [
|
13
|
-
{
|
14
|
-
name: 'title',
|
15
|
-
type: 'text',
|
16
|
-
},
|
17
|
-
{
|
18
|
-
name: 'author',
|
19
|
-
type: 'relationship',
|
20
|
-
relationTo: 'users',
|
21
|
-
},
|
22
|
-
{
|
23
|
-
name: 'publishedDate',
|
24
|
-
type: 'date',
|
25
|
-
},
|
26
|
-
{
|
27
|
-
name: 'category',
|
28
|
-
type: 'relationship',
|
29
|
-
relationTo: 'categories'
|
30
|
-
},
|
31
|
-
{
|
32
|
-
name: 'tags',
|
33
|
-
type: 'relationship',
|
34
|
-
relationTo: 'tags',
|
35
|
-
hasMany: true,
|
36
|
-
},
|
37
|
-
{
|
38
|
-
name: 'content',
|
39
|
-
type: 'richText'
|
40
|
-
},
|
41
|
-
{
|
42
|
-
name: 'status',
|
43
|
-
type: 'select',
|
44
|
-
options: [
|
45
|
-
{
|
46
|
-
value: 'draft',
|
47
|
-
label: 'Draft',
|
48
|
-
},
|
49
|
-
{
|
50
|
-
value: 'published',
|
51
|
-
label: 'Published',
|
52
|
-
},
|
53
|
-
],
|
54
|
-
defaultValue: 'draft',
|
55
|
-
admin: {
|
56
|
-
position: 'sidebar',
|
57
|
-
}
|
58
|
-
}
|
59
|
-
],
|
60
|
-
}
|
61
|
-
|
62
|
-
export default Posts;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { CollectionConfig } from 'payload/types';
|
2
|
-
|
3
|
-
const Tags: CollectionConfig = {
|
4
|
-
slug: 'tags',
|
5
|
-
admin: {
|
6
|
-
useAsTitle: 'name',
|
7
|
-
},
|
8
|
-
access: {
|
9
|
-
read: () => true,
|
10
|
-
},
|
11
|
-
fields: [
|
12
|
-
{
|
13
|
-
name: 'name',
|
14
|
-
type: 'text',
|
15
|
-
},
|
16
|
-
],
|
17
|
-
timestamps: false,
|
18
|
-
}
|
19
|
-
|
20
|
-
export default Tags;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { CollectionConfig } from 'payload/types';
|
2
|
-
|
3
|
-
const Users: CollectionConfig = {
|
4
|
-
slug: 'users',
|
5
|
-
auth: true,
|
6
|
-
admin: {
|
7
|
-
useAsTitle: 'email',
|
8
|
-
},
|
9
|
-
fields: [
|
10
|
-
// Email added by default
|
11
|
-
{
|
12
|
-
name: 'name',
|
13
|
-
type: 'text',
|
14
|
-
}
|
15
|
-
],
|
16
|
-
};
|
17
|
-
|
18
|
-
export default Users;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { buildConfig } from 'payload/config';
|
2
|
-
import path from 'path';
|
3
|
-
import Categories from './collections/Categories';
|
4
|
-
import Posts from './collections/Posts';
|
5
|
-
import Tags from './collections/Tags';
|
6
|
-
import Users from './collections/Users';
|
7
|
-
import Media from './collections/Media';
|
8
|
-
|
9
|
-
export default buildConfig({
|
10
|
-
serverURL: 'http://localhost:3000',
|
11
|
-
admin: {
|
12
|
-
user: Users.slug,
|
13
|
-
},
|
14
|
-
collections: [Categories, Posts, Tags, Users, Media],
|
15
|
-
typescript: {
|
16
|
-
outputFile: path.resolve(__dirname, 'payload-types.ts'),
|
17
|
-
},
|
18
|
-
graphQL: {
|
19
|
-
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
|
20
|
-
},
|
21
|
-
})
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import express from 'express';
|
2
|
-
import payload from 'payload';
|
3
|
-
|
4
|
-
require('dotenv').config();
|
5
|
-
const app = express();
|
6
|
-
|
7
|
-
// Redirect root to Admin panel
|
8
|
-
app.get('/', (_, res) => {
|
9
|
-
res.redirect('/admin');
|
10
|
-
});
|
11
|
-
|
12
|
-
const start = async () => {
|
13
|
-
// Initialize Payload
|
14
|
-
await payload.init({
|
15
|
-
secret: process.env.PAYLOAD_SECRET,
|
16
|
-
mongoURL: process.env.MONGODB_URI,
|
17
|
-
express: app,
|
18
|
-
onInit: async () => {
|
19
|
-
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
20
|
-
},
|
21
|
-
})
|
22
|
-
|
23
|
-
// Add your own express routes here
|
24
|
-
|
25
|
-
app.listen(3000);
|
26
|
-
}
|
27
|
-
|
28
|
-
start();
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import { CollectionConfig } from 'payload/types';
|
2
|
-
|
3
|
-
const Todo: CollectionConfig = {
|
4
|
-
slug: 'todos',
|
5
|
-
admin: {
|
6
|
-
defaultColumns: ['listName', 'tasks', 'updatedAt'],
|
7
|
-
useAsTitle: 'listName',
|
8
|
-
},
|
9
|
-
access: {
|
10
|
-
create: () => true,
|
11
|
-
read: () => true,
|
12
|
-
update: () => true,
|
13
|
-
delete: () => true,
|
14
|
-
},
|
15
|
-
fields: [
|
16
|
-
{
|
17
|
-
name: 'listName',
|
18
|
-
type: 'text',
|
19
|
-
},
|
20
|
-
{
|
21
|
-
name: 'tasks',
|
22
|
-
type: 'array',
|
23
|
-
fields: [
|
24
|
-
{
|
25
|
-
name: 'name',
|
26
|
-
type: 'text',
|
27
|
-
},
|
28
|
-
{
|
29
|
-
name: 'complete',
|
30
|
-
type: 'checkbox',
|
31
|
-
defaultValue: false,
|
32
|
-
}
|
33
|
-
]
|
34
|
-
},
|
35
|
-
],
|
36
|
-
}
|
37
|
-
|
38
|
-
export default Todo;
|