sp-rest-proxy icon indicating copy to clipboard operation
sp-rest-proxy copied to clipboard

Typescript import

Open PowellT opened this issue 3 years ago • 1 comments

React app, using typescript. version 3.2.2 of the sp-rest-proxy

I am not understanding your intructions for typescript. You include the following in the docs: import RestProxy, { IProxySettings } from 'sp-rest-proxy/dist/RestProxy';

const settings: IProxySettings = { configPath: './config/private.json' };

const restProxy = new RestProxy(settings); restProxy.serve();

But I dont know where this is supposed to go, serve.js? Any guidance appreciated .

PowellT avatar Oct 13 '22 17:10 PowellT

sp-rest-proxy is a Node.js library. So you won't import it in a React/Frontend sources as such code can't be bundled for a browser.

Proxy is a "side car" process which runs as Node server next to local dev server.

Usually, a client side project's TypeScript settings are different from a server side TypeScript project and it could be not a straight forward to configure both within the same code base. At the same time, it's a little scaffolding code you need for a proxy server.js. I'd recommend just following these steps for simplicity.

If your dev tools expose WebPack - this approach can be handy.

Hope this helps.

koltyakov avatar Oct 13 '22 18:10 koltyakov