Refactor route handlers and CMS clients
Refactored the route handlers to use a new `enhanceRouteHandler` function for better control over request handlers and user authentication. CMS clients are now created using factory functions for better encapsulation and control over instance creation. Renamed `client.ts` in 'keystatic' to `keystatic-client.ts`.
This commit is contained in:
@@ -28,9 +28,11 @@ async function cmsClientFactory(type: CmsType) {
|
||||
}
|
||||
|
||||
async function getWordpressClient() {
|
||||
const { WordpressClient } = await import('../../wordpress/src/wp-client');
|
||||
const { createWordpressClient } = await import(
|
||||
'../../wordpress/src/wp-client'
|
||||
);
|
||||
|
||||
return new WordpressClient();
|
||||
return createWordpressClient();
|
||||
}
|
||||
|
||||
async function getKeystaticClient() {
|
||||
@@ -38,9 +40,11 @@ async function getKeystaticClient() {
|
||||
process.env.NEXT_RUNTIME === 'nodejs' ||
|
||||
process.env.KEYSTATIC_STORAGE_KIND !== 'local'
|
||||
) {
|
||||
const { KeystaticClient } = await import('../../keystatic/src/client');
|
||||
const { createKeystaticClient } = await import(
|
||||
'../../keystatic/src/keystatic-client'
|
||||
);
|
||||
|
||||
return new KeystaticClient();
|
||||
return createKeystaticClient();
|
||||
}
|
||||
|
||||
console.error(
|
||||
|
||||
Reference in New Issue
Block a user