routes/wp-importer
Functions
'Read the “', Functions, '” section'function POST(context: APIContext<Record<string, any>, Record<string, undefined | string>>): Response | Promise<Response>
Defined in: studiocms/packages/studiocms_devapps/src/routes/wp-importer.ts:33
Handles the POST request for importing data from a WordPress site.
Parameters
'Read the “', Parameters, '” section'APIContext
<Record
<string
, any
>, Record
<string
, undefined
| string
>>
The context of the API request.
Response
| Promise
<Response
>
The response object indicating the result of the import operation.
The function expects the request to contain form data with the following fields:
url
: The URL of the WordPress site to import data from.type
: The type of data to import (e.g., ‘pages’, ‘posts’, ‘settings’).useBlogPlugin
(optional): A boolean value indicating whether to use the blog plugin for importing posts.
The function performs the following steps:
- Extracts the form data from the request.
- Validates the presence and types of the
url
andtype
fields. - Logs the import operation details.
- Based on the
type
field, calls the appropriate import function:importPagesFromWPAPI
for importing pages.importPostsFromWPAPI
for importing posts, optionally using the blog plugin.importSettingsFromWPAPI
for importing settings.
- Returns a response indicating success or failure.
If the type
field contains an invalid value.