chore: revert #1794 for now until permanent init architecture is established
This commit is contained in:
@@ -25,25 +25,24 @@ payload.init({
|
||||
secret: 'PAYLOAD_SECRET_KEY',
|
||||
mongoURL: 'mongodb://localhost/payload',
|
||||
express: app,
|
||||
onInit: async () => {
|
||||
const router = express.Router();
|
||||
});
|
||||
|
||||
router.use(payload.authenticate); // highlight-line
|
||||
const router = express.Router();
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
if (req.user) {
|
||||
return res.send(`Authenticated successfully as ${req.user.email}.`);
|
||||
}
|
||||
router.use(payload.authenticate); // highlight-line
|
||||
|
||||
return res.send('Not authenticated');
|
||||
});
|
||||
router.get('/', (req, res) => {
|
||||
if (req.user) {
|
||||
return res.send(`Authenticated successfully as ${req.user.email}.`);
|
||||
}
|
||||
|
||||
app.use('/some-route-here', router);
|
||||
return res.send('Not authenticated');
|
||||
});
|
||||
|
||||
app.listen(3000, async () => {
|
||||
payload.logger.info(`listening on ${3000}...`);
|
||||
});
|
||||
},
|
||||
app.use('/some-route-here', router);
|
||||
|
||||
app.listen(3000, async () => {
|
||||
payload.logger.info(`listening on ${3000}...`);
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
@@ -66,7 +66,7 @@ app.listen(3000, async () => {
|
||||
});
|
||||
```
|
||||
|
||||
This server doesn't do anything just yet. But, after you have this in place, we can initialize Payload via its `init()` method, which accepts a small set of arguments to tell it how to operate. For a full list of `init` arguments, please consult the [main configuration](/docs/configuration/overview) docs.
|
||||
This server doesn't do anything just yet. But, after you have this in place, we can initialize Payload via its `init()` method, which accepts a small set of arguments to tell it how to operate. For a full list of `init` arguments, please consult the [main configuration](/docs/configuration/overview#init) docs.
|
||||
|
||||
To initialize Payload, update your `server.js` file to reflect the following code:
|
||||
|
||||
@@ -80,13 +80,12 @@ payload.init({
|
||||
secret: 'SECRET_KEY',
|
||||
mongoURL: 'mongodb://localhost/payload',
|
||||
express: app,
|
||||
onInit: () => {
|
||||
app.listen(3000, async () => {
|
||||
console.log('Express is now listening for incoming connections on port 3000.')
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
app.listen(3000, async () => {
|
||||
console.log('Express is now listening for incoming connections on port 3000.')
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
Here is a list of all properties available to pass through `payload.init`:
|
||||
|
||||
Reference in New Issue
Block a user