Skip to content

Custom REST endpoints #532

Answered by denolfe
BrettBedarf asked this question in Q&A
Discussion options

You must be logged in to vote

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 a…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zubricks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants