* added Logout documentation * updated type and schema * updated logout component, route and inactivityRoute references * added custom Logout component into test admin instance * fixed windows path management * added dotenv usage * added check on testSuiteDir and provided more meaningful error message * fixed object destructure * updated from logout.route to logoutRoute * extracted getSanitizedLogoutRoutes method * added unit tests * updated references * updated doc * reviewed casing and added defaults * updated usage * restored workers previous value * fixed config validation * updated docs and schema * updated reference to logoutRoute and inactivityRoute * updated test ref Co-authored-by: Alberto Maghini (MSC Technology Italia) <alberto.maghini@msc.com> Co-authored-by: Alberto Maghini <alberto@newesis.com>
38 lines
927 B
TypeScript
38 lines
927 B
TypeScript
import express from 'express';
|
|
import { v4 as uuid } from 'uuid';
|
|
import payload from '../src';
|
|
|
|
require("dotenv").config();
|
|
const expressApp = express();
|
|
const init = async () => {
|
|
await payload.initAsync({
|
|
secret: uuid(),
|
|
mongoURL: process.env.MONGO_URL || 'mongodb://localhost/payload',
|
|
express: expressApp,
|
|
email: {
|
|
logMockCredentials: true,
|
|
fromName: 'Payload',
|
|
fromAddress: 'hello@payloadcms.com',
|
|
},
|
|
onInit: async (app) => {
|
|
app.logger.info('Payload Dev Server Initialized');
|
|
},
|
|
});
|
|
|
|
// Redirect root to Admin panel
|
|
expressApp.get('/', (_, res) => {
|
|
res.redirect('/admin');
|
|
});
|
|
|
|
const externalRouter = express.Router();
|
|
|
|
externalRouter.use(payload.authenticate);
|
|
|
|
expressApp.listen(3000, async () => {
|
|
payload.logger.info(`Admin URL on ${payload.getAdminURL()}`);
|
|
payload.logger.info(`API URL on ${payload.getAPIURL()}`);
|
|
});
|
|
};
|
|
|
|
init();
|