Skip to content

Commit c73a736

Browse files
committed
format fix
1 parent efe26ea commit c73a736

File tree

4 files changed

+14338
-11527
lines changed

4 files changed

+14338
-11527
lines changed
Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,55 @@
11
import {
2-
createIntegration,
3-
FetchEventCallback,
4-
FetchPublishScriptEventCallback,
5-
RuntimeContext,
6-
RuntimeEnvironment
7-
} from '@gitbook/runtime'
8-
import { VoteBlock } from './vote-block'
2+
createIntegration,
3+
FetchEventCallback,
4+
FetchPublishScriptEventCallback,
5+
RuntimeContext,
6+
RuntimeEnvironment,
7+
} from '@gitbook/runtime';
8+
import { VoteBlock } from './vote-block';
99

1010
// @ts-ignore
1111
// eslint-disable-next-line import/no-unresolved
12-
import script from './script.raw.js?raw' // the generated string module
12+
import script from './script.raw.js?raw'; // the generated string module
1313

1414
type VaultriceContext = RuntimeContext<
15-
RuntimeEnvironment<
16-
{},
17-
{
18-
projectId?: string;
19-
apiKey?: string;
20-
apiSecret?: string;
21-
}
22-
>
23-
>
15+
RuntimeEnvironment<
16+
{},
17+
{
18+
projectId?: string;
19+
apiKey?: string;
20+
apiSecret?: string;
21+
}
22+
>
23+
>;
2424

2525
/**
2626
* serve the published script: return JS string with placeholders replaced
2727
*/
28-
export const handleFetchPublishedScript: FetchPublishScriptEventCallback = async (event, { environment }: VaultriceContext) => {
29-
return new Response(script as string, {
30-
headers: {
31-
'Content-Type': 'application/javascript',
32-
'Cache-Control': 'public, max-age=3600'
33-
}
34-
})
35-
}
28+
export const handleFetchPublishedScript: FetchPublishScriptEventCallback = async (
29+
event,
30+
{ environment }: VaultriceContext,
31+
) => {
32+
return new Response(script as string, {
33+
headers: {
34+
'Content-Type': 'application/javascript',
35+
'Cache-Control': 'public, max-age=3600',
36+
},
37+
});
38+
};
3639

3740
/**
3841
* Generic HTTP handler (GitBook calls /integration)
3942
*/
4043
export const handleFetch: FetchEventCallback = async (request, context) => {
41-
const url = new URL(request.url)
42-
const path = url.pathname
44+
const url = new URL(request.url);
45+
const path = url.pathname;
4346

44-
if (path.endsWith('voting.js') && url.searchParams.get('script') === 'true') {
45-
return handleFetchPublishedScript(request as any, context as any) as any
46-
}
47+
if (path.endsWith('voting.js') && url.searchParams.get('script') === 'true') {
48+
return handleFetchPublishedScript(request as any, context as any) as any;
49+
}
4750

48-
return new Response(
49-
`<!doctype html>
51+
return new Response(
52+
`<!doctype html>
5053
<html>
5154
<head>
5255
<meta charset="utf-8" />
@@ -76,17 +79,17 @@ export const handleFetch: FetchEventCallback = async (request, context) => {
7679
</script>
7780
</body>
7881
</html>`,
79-
{
80-
headers: {
81-
'Content-Type': 'text/html',
82-
'Cache-Control': 'public, max-age=86400'
83-
},
84-
}
85-
)
86-
}
82+
{
83+
headers: {
84+
'Content-Type': 'text/html',
85+
'Cache-Control': 'public, max-age=86400',
86+
},
87+
},
88+
);
89+
};
8790

8891
export default createIntegration({
89-
fetch: handleFetch,
90-
fetch_published_script: handleFetchPublishedScript,
91-
components: [VoteBlock]
92-
})
92+
fetch: handleFetch,
93+
fetch_published_script: handleFetchPublishedScript,
94+
components: [VoteBlock],
95+
});

0 commit comments

Comments
 (0)