Custom REST endpoints #532
Answered
by
denolfe
BrettBedarf
asked this question in
Q&A
-
Is it possible to add custom REST endpoints? |
Beta Was this translation helpful? Give feedback.
Answered by
denolfe
Apr 18, 2022
Replies: 1 comment
-
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 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 👍 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
zubricks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 thepayload.init
call.Hopefully, that answers your question. Let me know if you have a…