Decouple the Express Server from Payload #5445
vixalien
started this conversation in
Feature Requests & Ideas
Replies: 1 comment 1 reply
-
Hey @vixalien, Payload is being built to run on next in v3 which is currently in alpha and going to be beta very soon. In v3 we've removed express as a dependency and in future projects anyone who wants express will have to bring it into their app explicitly and run it alongside of next. Take a look at the larger move to next discussion for more info: #4202 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, the
payload
package acts like both a server and a client, as explained below:As a client
payload.init
initializes a "client" in the sense that it allows you to use the instance ofpayload
to access the API, and other functionality in your application.As a server
payload.init
also requires anexpress
option to attach itself to an express instance so that it can create routes for the Admin UI and manage user authentication.Decoupling
In my opinion, the express server should be separate from the payload client. This is because sometimes you just want to use the payload client API to access your payload data (pages, posts, etc.) without needing to expose the express Admin UI at all.
Furthermore, the express Admin UI complicates project hosting in serverless environments, as it expects a "normal" filesystem where compiled payload sources are stored. This creates complications in serverless environments as all files are bundled into one, and makes debugging harder. Furthermore, some serverless environments like Cloudflare Workers or Deno don't even support node packages (
fs
,path
, ...) and as such payload cannot work on them since it depends onexpress
.Proposal
I would hence propose separating these into two different packages,
payload-client
for the API client, andpayload-admin
for the express-based Admin UI. Further discussions would be needed to ensure user auth works correctly.This would allow payload-based to be hosted in the following nice format:
example.com
: a website that renders pages normally using thepayload-client
. This site could be built with any framework and possibly hosted on serverless environments.admin.example.com
(or subpath'ed atexample.com/admin
): a simple express app that just hosts the Payload Admin.Beta Was this translation helpful? Give feedback.
All reactions