# Setting Up New Outbound Feeds Repositories

Source: https://dev.arcxp.com/arc-io/developer-docs/setting-up-new-outbound-feeds-repositories/

Setting up new outbound feeds repositories

## Prerequisites

- `node` / `npm` installed (node version > 10).
- Docker

## Setting up outbound feeds repositories

### Outbound feeds starter repo

You can view the starter repository at [/arcxp/OBF-Starter](https://github.com/arcxp/OBF-Starter).

### Creating a local repo

Clone your outbound feeds repository to your local machine. In the arcxp-ce-support GitHub account your repo will be named ORG-outboundfeeds, use your Arc organization name in place of ORG. For example, if your organization name is demo, your repository name would be demo-outboundfeeds.

`git clone git@github.com:arcxp-ce-support/ORG-outboundfeeds.git`

### Creating a read-only personal access token in github

To be able to run locally or deploy outbound feeds you need to create a read-only token in [GitHub](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token). This token needs to be added to your `.npmrc` file and will allow you to view and install Outbound Feeds blocks. If you have an `.npmrc` file you use for themes development, you can use the same file for Outbound Feeds development. The `.npmrc` file must never be added to the repo or checked in. Please use the following format when setting up your `.npmrc`:

Terminal window

```bash
@wpmedia:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=<your personal access token>
```

### Installing `npm` packages

Even if you are not going to do local development, you need to install the fusion-cli and its dependencies to be able to create bundles to upload to outbound feeds. Check to see what the latest version of the @arc-fusion/cli is and update your `package.json` to that version.

Terminal window

```bash
npm install
```

### Creating a `.env`

Copy the `env.example` to `.env` and edit the file to replace the placeholders with your correct values. The `CONTENT_BASE` and `ARC_ACCESS_TOKEN` values are for content sources to access your Production or Sandbox environments. You probably already use these in your other fusion repository.

- `CONTENT_BASE` \- Set your org in `https://api.{ORG}.arcpublishing.com`. This is used by content sources to get data from your Production or Sandbox environment. Replace `ORG` with your org name, like `demo` or `sandbox.demo`. This should point to your Production or Sandbox environments, not the OBF environments. For more information, see [Using Developer Access Tokens to Access the Arc XP APIs](https://dev.arcxp.com/api/accessing-arcxp-apis/).
- `ARC_ACCESS_TOKEN` \- Your readonly developer token. This is used by content sources to get data from your Production or Sandbox environment. If you have a developer token for your website or other Arc XP development, use that. This should be from your Production or Sandbox environments, not the OBF environments. For more information, see [Using Developer Access Tokens to Access the Arc XP APIs](https://dev.arcxp.com/api/accessing-arcxp-apis/).
- `resizerKey` \- Your organization’s Image Resizer key. If you don’t know your key, contact [Arc XP Customer Support](https://support.arcpublishing.com/).
- `BLOCK_DIST_TAG` \- To use Production blocks, set this to `stable`. To use development blocks, set this `beta`. Engine defaults to `stable` if not set.
- `FUSION_RELEASE` \- Set this to the latest PageBuilder Engine version. When a new version becomes available, update this to the latest version and validate your environment locally.

The `.env` file is in `.gitignore` and should never be checked into GitHub.

### Updating Mock websites

When running the editor locally, the list of websites comes from a local file instead of your site service. To have your websites used, you must update the mock file `mocks/siteservice/api/v3/website` with your websites.

```json
[
  {
    "_id": "website1",
    "display_name": "Website 1",
    "is_default_website": true
  },
  {
    "_id": "website2",
    "display_name": "Website 2",
    "is_default_website": false
  }
]
```

Run Fusion locally:

Terminal window

```bash
npx fusion start
```

After Fusion finishes starting, you should be able to get to the PageBuilder Editor `http://localhost/pagebuilder/pages` and `http://localhost/pagebuilder/templates` to add and configure feeds locally. After you have created your templates and resolvers, you can use a tool like Postman to see them at `http://localhost/arc/outboundfeeds/{FEED_NAME}?outputType=xml&_website={WEBSITE}`.

Run tests with:

Terminal window

```bash
npm test
```

### Deploying

When you are ready to deploy the bundle, you must set up environment variables in the `environment/org-outboundfeeds.js` and `environment/org-outboundfeeds-sandbox.js` files. Use the values from your local `.env` to set the `DIST_TAG` and `resizerKey`. Rename the files, replacing the clients org name with `org` in the current names. You must encrypt any values that should not be made public (`resizerKey`).

Copy your `.npmrc` to `.npmrc-encrypted`. Using the Secrets tab in the Editor, encrypt your GitHub access token. Wrap the encrypted value with `%{ }`.

> **Note:**
> 
> If you are deploying to version 3.x, you do not need to create an `.npmrc-encrypted` file. If you are using `@arc-fusion/cli` 2.0.6 or later, it does not include your `.npmrc` in the bundle.

Terminal window

```bash
@wpmedia:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=%{ your encrypted personal access token }
```

When you are ready to deploy a bundle, run the `npx fusion zip` command. Running this command manually is fine to get started, but consider setting up a CI/CD process to automate this.

Terminal window

```bash
npx fusion zip
```
