{"id":25867312,"url":"https://github.com/johnfacey/ocapi-proxy","last_synced_at":"2025-03-02T03:34:39.167Z","repository":{"id":33675137,"uuid":"159555439","full_name":"johnfacey/ocapi-proxy","owner":"johnfacey","description":"Salesforce Commerce Cloud Node.js OCAPI Proxy Router","archived":false,"fork":false,"pushed_at":"2024-09-26T04:32:20.000Z","size":880,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-20T12:03:58.224Z","etag":null,"topics":["commerce-cloud","commercejs","demandware","javascript","node","nodejs","ocapi","proxy","proxy-server","router","salesforce","salesforce-commerce-cloud","salesforce-developers"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnfacey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"johnfacey","ko_fi":"johnfacey"}},"created_at":"2018-11-28T19:41:20.000Z","updated_at":"2025-01-04T13:25:11.000Z","dependencies_parsed_at":"2024-11-19T04:56:00.439Z","dependency_job_id":null,"html_url":"https://github.com/johnfacey/ocapi-proxy","commit_stats":{"total_commits":57,"total_committers":2,"mean_commits":28.5,"dds":0.08771929824561409,"last_synced_commit":"64b39f40af69024f38c1b5646b7d161115af376e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfacey%2Focapi-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfacey%2Focapi-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfacey%2Focapi-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfacey%2Focapi-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnfacey","download_url":"https://codeload.github.com/johnfacey/ocapi-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241455149,"owners_count":19965555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commerce-cloud","commercejs","demandware","javascript","node","nodejs","ocapi","proxy","proxy-server","router","salesforce","salesforce-commerce-cloud","salesforce-developers"],"created_at":"2025-03-02T03:34:38.301Z","updated_at":"2025-03-02T03:34:39.150Z","avatar_url":"https://github.com/johnfacey.png","language":"JavaScript","funding_links":["https://github.com/sponsors/johnfacey","https://ko-fi.com/johnfacey","https://ko-fi.com/M4M13CMPP"],"categories":[],"sub_categories":[],"readme":"# Salesforce Commerce Cloud OCAPI Proxy \r\n![version](https://img.shields.io/badge/Salesforce-OCAPIProxy-blue.svg)  ![version](https://img.shields.io/badge/version-2.2.2-green.svg)\r\n\r\n\r\n[![NPM](https://nodei.co/npm/ocapi-proxy.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/ocapi-proxy/)\r\n\r\nThis project will serve as a local Node.js based Proxy server that will forward requests to an Salesforce Commerce Cloud OCAPI instance. \r\nThis can be used for purposes such as testing 3rd party apps using OCAPI as well as integration for mobile/browser apps. \r\nThe configuration of site_id, client_id are configured at the proxy level rather than in the app directly. \r\n\r\n\r\n## Welcome: \r\n\r\n![Postman Example](./examples/OCAPI-Proxy-Setup.png)\r\n\r\n\r\n## Getting Started\r\n\r\nEdit the config.json to match the server you are using. \r\nIf you are using a service such as https://ngrok.com you may need to add the url to your Business Manager allowed origins.\r\n\r\n**NOTE:** This package only forwards OCAPI requests from one point to another. The main purpose is for routing data around CORS and is typically useful for Mobile Applications. x-dw-client-id as a header attribute must be used instead of client_id as a url parameter.\r\n\r\n## Updates\r\n\r\nUpdated UI Interface with Request and Response sections.\r\nRemoved Autolaunch of UI.\r\nCors changes to express have been added.\r\nUI can be compltely disabled in config.json as well as Google Anaylrics by making the value \"\"\r\nErrors will now return a json format if the SFCC instance can be reached. \r\nThis will resolve issues with Postman not getting back a json result and aid in debugging. \r\n\r\n## Prerequisites\r\n```\r\nRequired:\r\n    Node.js\r\n    Salesforce Commerce Cloud Sandbox - Configured for OCAPI\r\n\r\nOptional:\r\n    Postman or another rest API tool.\r\n    ngrok - If you need to get a public url to your localhost\r\n```\r\n## Installing\r\n```\r\nnpm install ocapi-proxy\r\n```\r\n\r\n## Running \r\n\r\nFrom the command line: \r\n```\r\nnpm start or node ocapi-proxy.js\r\n\r\n\r\n```\r\n\r\nExample:\r\n```\r\nnpm start ocapi-proxy.js\r\n```\r\n![Postman Example](./examples/pm2-example.png)\r\n\r\nYou will need a config.json (one will be generated on first launch)\r\nTo edit the port, domain, etc.. modify the config.json file. \r\nserver: your Salesforce Commerce Cloud server (currently all calls are https)\r\nsite_id: SFCC Site ID\r\nversion: SFCC OCAPI Version\r\nport_ui: Port for browser testing requests.\r\nport: Port that proxy listens for requests.\r\n\r\nExample:\r\n```\r\n{\r\n    \"server\": \"yoursandbox.demandware.net\",\r\n    \"site_id\": \"SiteGenesis\",\r\n    \"version\": \"v23_2\",\r\n    \"client_id\": \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\r\n    \"port\": 8080,\r\n    \"port_ui\": 80,\r\n    \"UA\": \"UA-XXXX-XXXX\",  //Optional: Universal Analytics ID\r\n    \"rate_limit\": \"\",  //Optional: 15 minutes default\r\n    \"rate_max\": \"\",  //Optional: number of calls that can be made\r\n    \"windowMs\": limit, // 15 minutes or config file entry\r\n    \"max\": max, // Limit each IP to 100 requests per `window` (here, per 15 minutes)\r\n}\r\n\r\n```\r\n\r\n## OCAPI Commands\r\n\r\nYou can send OCAPI commands to your local proxy. \r\nSpecify the host to make the call.\r\nSend the endpoint as the **callurl** header attribute.\r\nAll other attributes can be sent similar to a direct OCAPI call. \r\nThis ensures that the Proxy communicates with OCAPI as middleware.\r\n\r\nExample: \r\n\r\n![Postman Example](./examples/postman-example.png)\r\n\r\n## Deployment/Development\r\n\r\nThis is currently a work in progress. Please report any issues you find.\r\nLatest: Fixes to logging added dates to log files.\r\nUpdated contact info for [Github](https://github.com/johnfacey) and [Twitter](https://twitter.com/johnfacey).\r\n\r\n## OCAPI Output Modifications\r\n\r\nCurrently **Authorization** and **ETag**  headers are returned into the body from the output proxy rather than in the header. These are not needed in 19.X+\r\n\r\n## Universal Analytics\r\n\r\nThe Proxy will communicate with Google Universal Analytics if a \"UA\" attribute is found in the config file. You may leave this attribute blank or remove it from the config. Currently all UA requests are send as a event tag with the url of the Commerce Cloud Instance.\r\n\r\n## Proxy Testing UI\r\n\r\n![Postman Example](./examples/OCAPI-Proxy-Tester.png)\r\n\r\nNEW Proxy UI for testing from a web browser interface. Config attribute \"port_ui\" added to config.json\r\n\r\n## Files / Links\r\n* [**Postman Collection**](./examples/OCAPI-Proxy.postman_collection.json)\r\n* [**Example: config.json**](./sample-config.json)\r\n\r\n## File Structure\r\n```\r\nWithin the download you'll find the following directories and files:\r\n|-- Root\r\n    |-- .gitignore\r\n    |-- .npmignore\r\n    |-- build.js\r\n    |-- config.json\r\n    |-- ecosystem.config.js\r\n    |-- libProxy.js\r\n    |-- LICENSE.md\r\n    |-- ocapi-proxy.js\r\n    |-- package-lock.json\r\n    |-- package.json\r\n    |-- README.md\r\n    |-- sample-config.json\r\n    |-- SECURITY.md\r\n    |-- .vscode\r\n    |   |-- launch.json\r\n    |-- examples\r\n    |   |-- diagram-middleware.png\r\n    |   |-- OCAPI-Proxy-Tester.png\r\n    |   |-- OCAPI-Proxy.postman_collection.json\r\n    |   |-- pm2-example.png\r\n    |   |-- postman-example.png\r\n    |-- html\r\n    |   |-- index.html\r\n    |-- logs\r\n```\r\n\r\n## Logging\r\n\r\nThe Proxy will generate logs where the current proxy has been executed in the logs directory.\r\n\r\n## Built With\r\n\r\n* [**Node.js**](https://nodejs.org) \r\n* [**Express**](https://expressjs.com) - Minimalist Web Framework for Node.js\r\n* [**jsonfile**](https://www.npmjs.com/package/jsonfile) - read/write JSON files in Node.js\r\n* [**universal-analytics**](https://www.npmjs.com/package/universal-analytics) - Google Universal Analytics\r\n* [**open**](https://www.npmjs.com/package/open) - Open (NPM)\r\n* [**Mddir**](https://www.npmjs.com/package/mddir) - Mddir (NPM)\r\n\r\n\r\n## Authors\r\n\r\n* **John Facey II** - *Lead*  \r\n[![GitHub followers](https://img.shields.io/github/followers/johnfacey.svg?label=Follow\u0026style=social)](https://github.com/johnfacey)\r\n[![Twitter followers](https://img.shields.io/twitter/follow/johnfacey.svg?label=Follow\u0026style=social)](https://twitter.com/johnfacey)\r\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/M4M13CMPP)\r\n\r\n## License\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\nSee the [LICENSE.md](LICENSE.md) file for details\r\n\r\n## Acknowledgments\r\n\r\n* [**Salesforce Commerce Cloud**](https://www.salesforce.com/products/commerce-cloud/overview)\r\n* [**Node.js**](https://nodejs.org) \r\n* [**Visual Studio Code**](https://code.visualstudio.com)\r\n* [**ngrok**](https://ngrok.com)\r\n* [**jQuery**](https://jQuery.com)\r\n* [**Bootstrap**](https://getbootstrap.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnfacey%2Focapi-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnfacey%2Focapi-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnfacey%2Focapi-proxy/lists"}