-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathindex.html
200 lines (183 loc) · 5.35 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<title>graphql-http | GraphQL over HTTP spec compliance checker</title>
<meta
name="description"
content="Check any server for GraphQL over HTTP spec compliance with ease."
/>
<style>
*,
*:before,
*:after {
box-sizing: border-box;
}
body {
/* use system font */
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol';
}
input {
padding: 0.5em;
font-size: 1em;
width: 100%;
}
button {
cursor: pointer;
font-size: 1em;
}
#audit-server-form {
max-width: 512px;
margin: 0 auto;
}
fieldset {
padding: 1em;
}
#report {
max-width: 1024px;
margin: 2em auto;
padding: 2em;
border: 2px solid grey;
}
#report.hidden {
display: none;
}
#report.auditing {
color: grey;
background-color: lightgrey;
text-align: center;
}
#report.error {
color: red;
border-color: red;
}
li {
margin-bottom: 0.5em;
}
pre {
border: 1px solid grey;
padding: 1em;
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
summary {
cursor: pointer;
}
footer {
text-align: center;
margin-bottom: 2em;
}
.tip {
color: grey;
}
</style>
<!-- <graphql-http-audits.min.js> -->
<!-- the audits script will be injected as a part of the website deployment action -->
<!-- </graphql-http-audits.min.js> -->
</head>
<body>
<main>
<h1 style="text-align: center">
<a href="https://github.com/graphql/graphql-http">graphql-http</a>
</h1>
<p style="text-align: center; color: grey">
Simple, pluggable, zero-dependency, GraphQL over HTTP spec compliant
server, client and audit suite.
</p>
<br />
<form id="audit-server-form" name="audit-server">
<fieldset>
<legend>
Check for
<a href="https://graphql.github.io/graphql-over-http/"
>GraphQL over HTTP spec</a
>
compliance
</legend>
<div>
<label for="url">URL of server to audit:</label>
<br />
<input id="url" type="url" name="url" required autofocus />
<br />
<small
>Please make sure that
<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS"
>CORS</a
>
allows this origin on your server.</small
>
</div>
<br />
<div style="text-align: right">
<button type="submit">Audit</button>
</div>
</fieldset>
</form>
<div id="report" class="hidden"></div>
<p style="text-align: center">
<small class="tip"
><b>💡 Tip:</b> Save this website and use it as a portable offline
compliance checker.</small
>
</p>
<footer>
<small>
<a href="https://roadmap.sh/graphql">Learn GraphQL</a>
|
<a href="https://graphql.github.io/graphql-over-http/"
>GraphQL over HTTP spec</a
>
|
<a href="https://bundlephobia.com/package/graphql-http"
>Bundlephobia (package size)</a
>
|
<a href="https://github.com/graphql/graphql-http">GitHub</a>
|
<a href="https://www.npmjs.com/package/graphql-http">npm</a>
</small>
</footer>
</main>
<script>
const params = new URLSearchParams(window.location.search);
const url = params.get('url');
if (url) {
const urlInput = document.getElementById('url');
urlInput.setAttribute('value', url);
urlInput.setAttribute('disabled', true);
const reportDiv = document.getElementById('report');
reportDiv.classList.remove('hidden');
reportDiv.classList.add('auditing');
reportDiv.innerHTML = '⏳ Auditing...';
graphqlHttpAudits
.auditServer({ url })
.then((results) =>
graphqlHttpAudits
.renderAuditResultsToHTML(results)
.then((html) => (reportDiv.innerHTML = html)),
)
.catch((err) => {
console.error('Problem while auditing server', err);
reportDiv.classList.add('error');
reportDiv.innerHTML = `
<small class="tip"><b>💡 Tip:</b> Open the console to see more details about the error.</small>
<br /><br />
<pre style="border: 0; padding: 0">${
err instanceof Error
? err.message + '\n\n' + err.stack
: JSON.stringify(err, null, ' ')
}</pre>`;
})
.finally(() => {
urlInput.removeAttribute('disabled');
reportDiv.classList.remove('auditing');
});
}
</script>
</body>
</html>