Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript import #155

Open
PowellT opened this issue Oct 13, 2022 · 1 comment
Open

Typescript import #155

PowellT opened this issue Oct 13, 2022 · 1 comment

Comments

@PowellT
Copy link

PowellT commented Oct 13, 2022

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 .

@koltyakov
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants