first commit

This commit is contained in:
esthetech
2023-01-18 14:34:42 +01:00
committed by augurk
commit bdf11ce3b6
12 changed files with 6430 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import { CollectionConfig } from 'payload/types';
// Example Collection - For reference only, this must be added to payload.config.ts to be used.
const Examples: CollectionConfig = {
slug: 'examples',
admin: {
useAsTitle: 'someField',
},
fields: [
{
name: 'someField',
type: 'text',
},
],
}
export default Examples;

18
src/collections/Users.ts Normal file
View File

@ -0,0 +1,18 @@
import { CollectionConfig } from 'payload/types';
const Users: CollectionConfig = {
slug: 'users',
auth: true,
admin: {
useAsTitle: 'email',
},
access: {
read: () => true,
},
fields: [
// Email added by default
// Add more fields as needed
],
};
export default Users;

22
src/payload.config.ts Normal file
View File

@ -0,0 +1,22 @@
import { buildConfig } from 'payload/config';
import path from 'path';
// import Examples from './collections/Examples';
import Users from './collections/Users';
export default buildConfig({
serverURL: 'http://localhost:3000',
admin: {
user: Users.slug,
},
collections: [
Users,
// Add Collections here
// Examples,
],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
});

24
src/server.ts Normal file
View File

@ -0,0 +1,24 @@
import express from 'express';
import payload from 'payload';
require('dotenv').config();
const app = express();
// Redirect root to Admin panel
app.get('/', (_, res) => {
res.redirect('/admin');
});
// Initialize Payload
payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
onInit: () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
},
})
// Add your own express routes here
app.listen(3000);