Is it possible to add custom REST endpoints?
Hey @BrettBedarf, good question. Since Payload simply takes your express app as a parameter, you still have full access to it to add any additional functionality as needed. Here is an example server.ts
that is generated runningnpx create-payload-app
. You would simply add your additional functionality after the payload.init
call.
import express from 'express';
import payload from 'payload';
require('dotenv').config();
const app = express();
// Initialize Payload
payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
})
// Add your own express routes here
app.listen(3000);
Hopefully, that answers your question. Let me know if you have any follow up questions 👍
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.