monorise 1.14.0 → 1.15.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base/index.d.ts +219 -1
- package/dist/base/index.js +381 -1
- package/dist/base/index.js.map +1 -1
- package/dist/cli/cli.js +291 -122
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/templates/files/proxy-route.ts +12 -22
- package/dist/cli/templates/files/sst.config.ts +4 -1
- package/dist/cli/templates/files/ws-ticket-route.ts +21 -0
- package/dist/core/index.d.ts +55 -20
- package/dist/core/index.js +743 -128
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +23 -0
- package/dist/proxy/index.d.ts +270 -2
- package/dist/proxy/index.js +645 -37
- package/dist/proxy/index.js.map +1 -1
- package/dist/react/actions/core.action.d.ts.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +33 -60
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/templates/files/proxy-request.ts +0 -50
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { NextRequest } from 'next/server';
|
|
2
|
-
import { Resource } from 'sst';
|
|
3
|
-
|
|
4
|
-
function rewriteUrl({
|
|
5
|
-
requestUrl,
|
|
6
|
-
replacePath,
|
|
7
|
-
}: {
|
|
8
|
-
requestUrl: string;
|
|
9
|
-
replacePath?: string;
|
|
10
|
-
}) {
|
|
11
|
-
const API_BASE_URL = process.env.API_BASE_URL;
|
|
12
|
-
const tobeReplacedPath =
|
|
13
|
-
replacePath ?? requestUrl.replace(/^https?:\/\/[^\/]+\/api\//, '');
|
|
14
|
-
|
|
15
|
-
return `${API_BASE_URL}/${tobeReplacedPath}`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const proxyRequest = async ({
|
|
19
|
-
req,
|
|
20
|
-
path,
|
|
21
|
-
}: {
|
|
22
|
-
req: NextRequest;
|
|
23
|
-
path?: string;
|
|
24
|
-
}): Promise<Response> => {
|
|
25
|
-
let body: string | undefined = undefined;
|
|
26
|
-
try {
|
|
27
|
-
body = JSON.stringify(await req.json());
|
|
28
|
-
} catch (err) {}
|
|
29
|
-
|
|
30
|
-
const reqHeaders: Record<string, string> = {};
|
|
31
|
-
req.headers.forEach((value, key) => {
|
|
32
|
-
if (['content-length'].includes(key)) return;
|
|
33
|
-
reqHeaders[key] = value;
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const resp = await fetch(
|
|
37
|
-
rewriteUrl({ requestUrl: req.url, replacePath: path }),
|
|
38
|
-
{
|
|
39
|
-
method: req.method,
|
|
40
|
-
body,
|
|
41
|
-
headers: {
|
|
42
|
-
...reqHeaders,
|
|
43
|
-
'x-api-key': Resource.X_API_KEY.value,
|
|
44
|
-
},
|
|
45
|
-
cache: 'no-store',
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return resp;
|
|
50
|
-
};
|