1
const payload = require('payload');
2
const express = require('express');
3
4
const app = express();
5
6
// Just pass your app into Payload and everything
7
// will be scoped to Payload routers.
8
9
payload.init({
10
secret: 'XXXXXXXXXXXXXXXXXXXXXXXXX',
11
express: app,
12
});
13
14
app.listen(process.env.PORT, () => {
15
console.log(\`Application listening on \${3000}...\`);
16
});
17
1
const Customers = {
2
// ...
3
hooks: {
4
beforeChange: [
5
// Before the Customer is created or updated,
6
// sync it to Hubspot
7
syncCustomerToHubspot,
8
],
9
afterChange: [
10
// Send the new Customer a welcome email
11
// after it's successfully created
12
sendWelcomeEmail,
13
],
14
afterRead: [
15
// Dynamically append user's active subscriptions
16
// straight from Stripe
17
addStripeSubscriptions,
18
],
19
},
20
};
21
1
const Orders = {
2
// ...
3
access: {
4
create: () => true, // Everyone can create
5
read: ({ req: { user } }) => {
6
if (user) {
7
return { // Users can only read their own
8
owner: { equals: user.id, },
9
};
10
}
11
12
return false; // Not logged in? Can't read any
13
},
14
update: ({ req: { user } }) => {
15
// Only Admins can update Orders
16
if (user.roles.includes('admin')) return true;
17
return false;
18
},
19
delete: () => false, // No one can delete
20
},
21
};
22

Payload provides solutions, not roadblocks.

You can host it yourself, or let us handle hosting for you on Payload Cloud.