# File Pre-Export

The pre-export app allows you to modify the strings before the file export. This type of app works with both the source strings and their respective translations.

[File Pre-Export Processing Module](https://support.crowdin.com/developer/crowdin-apps-module-file-pre-export-processing/)

## Sample

```js ins="filePreExport" title="index.js"
    import crowdinModule from '@crowdin/app-project-module';

    const configuration = {
      baseUrl: 'https://123.ngrok.io',
      clientId: 'clientId',
      clientSecret: 'clientSecret',
      name: 'Sample App',
      identifier: 'sample-app',
      description: 'Sample App description',
      dbFolder: import.meta.dirname,
      imagePath: import.meta.dirname + '/logo.png',
      filePreExport: [
        {
          filesFolder: `${import.meta.dirname}/db`,
          signaturePatterns: {
            fileName: "^.+\\..+$",
            fileContent: ".*"
          },
          fileProcess: async ({ request, content, client, context, projectId }) => {
            return { strings: [] };
          }
        }
      ]
    };

    crowdinModule.createApp(configuration);
    ```
  ```ts ins="filePreExport" title="index.ts"
    import crowdinModule from '@crowdin/app-project-module';
    import type { ClientConfig } from '@crowdin/app-project-module';

    const configuration: ClientConfig = {
      baseUrl: 'https://123.ngrok.io',
      clientId: 'clientId',
      clientSecret: 'clientSecret',
      name: 'Sample App',
      identifier: 'sample-app',
      description: 'Sample App description',
      dbFolder: import.meta.dirname,
      imagePath: import.meta.dirname + '/logo.png',
      filePreExport: [
        {
          filesFolder: `${import.meta.dirname}/db`,
          signaturePatterns: {
            fileName: "^.+\\..+$",
            fileContent: ".*"
          },
          fileProcess: async ({ request, content, client, context, projectId }) => {
            return { strings: [] };
          }
        }
      ]
    };

    crowdinModule.createApp(configuration);
    ```
  ## Configuration

| Parameter<div class="w-40"/> | Description                                                                                                                           |
|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `filesFolder`                | Folder where large files are temporarily stored.                                                                                      |
| `signaturePatterns`          | Contains `fileName` and/or `fileContent` regular expressions used to detect file type when uploading a new source file via UI or API. |

### `fileProcess` Function

This function is called before exporting the file.

##### Parameters

- `request` - Request object.
- `content` - Strings to be processed (an array of [`ProcessFileString`](https://support.crowdin.com/developer/crowdin-apps-module-custom-file-format/#strings-array-structure) objects).
- `client` - Crowdin API client.
- `context` - [Context object](/app-project-module/reference/context/).
- `projectId` - Crowdin project ID.

##### Return Value

The function should return an object with the following properties:

```yml
{
  strings: ProcessFileString[];
  error?: string;
  notModified?: boolean;
}
```

**Description:**

- `strings` - the processed strings (an array of [`ProcessFileString`](https://support.crowdin.com/developer/crowdin-apps-module-custom-file-format/#strings-array-structure) objects).
- `notModified` - optional, should be set to `true` if the file processor does not make any changes to the file.
- `error` - optional, and should contain an error message if the file processor encounters an error.