galbe 0.11.0 → 0.12.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.
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Galbe test</title>
7
+ <!-- <link rel="stylesheet" href="styles.css" /> -->
8
+ </head>
9
+ <body>
10
+ <h1>Bonjour</h1>
11
+ <p>This is a test page.</p>
12
+ </body>
13
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Galbe test: sub page</title>
7
+ <!-- <link rel="stylesheet" href="styles.css" /> -->
8
+ </head>
9
+ <body>
10
+ <h1>Hello</h1>
11
+ <p>This is a sub test page.</p>
12
+ </body>
13
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Galbe test: other page</title>
7
+ <!-- <link rel="stylesheet" href="styles.css" /> -->
8
+ </head>
9
+ <body>
10
+ <h1>Hola</h1>
11
+ <p>This is another test page.</p>
12
+ </body>
13
+ </html>
@@ -17,7 +17,7 @@ const rsTxt = (text: string) => {
17
17
  const words = text.split(' ')
18
18
  for (const w of words) controller.enqueue(w)
19
19
  controller.close()
20
- }
20
+ },
21
21
  })
22
22
  }
23
23
 
@@ -30,8 +30,8 @@ describe('responses', () => {
30
30
  galbe.post(
31
31
  '/none',
32
32
  {
33
- body: $T.optional($T.object($T.any())),
34
- query: { text: $T.optional($T.string()), stream: $T.optional($T.string()) }
33
+ body: { json: $T.optional($T.object($T.any())) },
34
+ query: { text: $T.optional($T.string()), stream: $T.optional($T.string()) },
35
35
  },
36
36
  ctx => {
37
37
  if (ctx.query.text) {
@@ -67,7 +67,7 @@ describe('responses', () => {
67
67
  test('response, no schema, string', async () => {
68
68
  const reqTxt = 'Hello Mom!'
69
69
  let resp = await fetch(`http://localhost:${port}/none?text=${reqTxt}`, {
70
- method: 'POST'
70
+ method: 'POST',
71
71
  })
72
72
 
73
73
  const body = await resp.text()
@@ -83,8 +83,8 @@ describe('responses', () => {
83
83
  method: 'POST',
84
84
  body: JSON.stringify(reqBody),
85
85
  headers: {
86
- 'content-type': 'application/json'
87
- }
86
+ 'content-type': 'application/json',
87
+ },
88
88
  })
89
89
 
90
90
  const body = await resp.json()
@@ -102,8 +102,8 @@ describe('responses', () => {
102
102
  let resp = await fetch(`http://localhost:${port}/none?text=${reqTxt}&stream=${c.stream}`, {
103
103
  method: 'POST',
104
104
  headers: {
105
- 'content-type': 'application/json'
106
- }
105
+ 'content-type': 'application/json',
106
+ },
107
107
  })
108
108
  const reader = resp.body?.getReader()
109
109
  let body = ''
@@ -126,8 +126,8 @@ describe('responses', () => {
126
126
  method: 'POST',
127
127
  body: bodyStr,
128
128
  headers: {
129
- 'content-type': 'application/octet-stream'
130
- }
129
+ 'content-type': 'application/octet-stream',
130
+ },
131
131
  })
132
132
 
133
133
  const reader = resp.body?.getReader()
@@ -154,8 +154,8 @@ describe('responses', () => {
154
154
  method: 'POST',
155
155
  body: bodyStr,
156
156
  headers: {
157
- 'content-type': 'text/plain'
158
- }
157
+ 'content-type': 'text/plain',
158
+ },
159
159
  })
160
160
 
161
161
  expect(resp.status).toBe(500)
@@ -169,8 +169,8 @@ describe('responses', () => {
169
169
  method: 'POST',
170
170
  body: bodyStr,
171
171
  headers: {
172
- 'content-type': 'application/json'
173
- }
172
+ 'content-type': 'application/json',
173
+ },
174
174
  })
175
175
 
176
176
  const body = await resp.json()
@@ -187,8 +187,8 @@ describe('responses', () => {
187
187
  method: 'POST',
188
188
  body: bodyStr,
189
189
  headers: {
190
- 'content-type': 'text/plain'
191
- }
190
+ 'content-type': 'text/plain',
191
+ },
192
192
  })
193
193
 
194
194
  expect(resp.status).toBe(500)
@@ -202,8 +202,8 @@ describe('responses', () => {
202
202
  method: 'POST',
203
203
  body: bodyStr,
204
204
  headers: {
205
- 'content-type': 'application/json'
206
- }
205
+ 'content-type': 'application/json',
206
+ },
207
207
  })
208
208
 
209
209
  const body = await resp.json()
@@ -220,8 +220,8 @@ describe('responses', () => {
220
220
  method: 'POST',
221
221
  body: bodyStr,
222
222
  headers: {
223
- 'content-type': 'application/json'
224
- }
223
+ 'content-type': 'application/json',
224
+ },
225
225
  })
226
226
 
227
227
  expect(resp.status).toBe(500)
@@ -234,8 +234,8 @@ describe('responses', () => {
234
234
  method: 'POST',
235
235
  body: bodyStr,
236
236
  headers: {
237
- 'content-type': 'text/plain'
238
- }
237
+ 'content-type': 'text/plain',
238
+ },
239
239
  })
240
240
 
241
241
  const body = await resp.text()
@@ -253,8 +253,8 @@ describe('responses', () => {
253
253
  method: 'POST',
254
254
  body: bodyStr,
255
255
  headers: {
256
- 'content-type': 'application/json'
257
- }
256
+ 'content-type': 'application/json',
257
+ },
258
258
  })
259
259
 
260
260
  const body = await resp.json()
@@ -271,8 +271,8 @@ describe('responses', () => {
271
271
  method: 'POST',
272
272
  body: bodyStr,
273
273
  headers: {
274
- 'content-type': 'application/json'
275
- }
274
+ 'content-type': 'application/json',
275
+ },
276
276
  })
277
277
 
278
278
  expect(resp.status).toBe(500)
@@ -286,8 +286,8 @@ describe('responses', () => {
286
286
  method: 'POST',
287
287
  body: bodyStr,
288
288
  headers: {
289
- 'content-type': 'application/json'
290
- }
289
+ 'content-type': 'application/json',
290
+ },
291
291
  })
292
292
 
293
293
  const body = await resp.json()
@@ -304,8 +304,8 @@ describe('responses', () => {
304
304
  method: 'POST',
305
305
  body: bodyStr,
306
306
  headers: {
307
- 'content-type': 'application/json'
308
- }
307
+ 'content-type': 'application/json',
308
+ },
309
309
  })
310
310
 
311
311
  expect(resp.status).toBe(500)
@@ -319,8 +319,8 @@ describe('responses', () => {
319
319
  method: 'POST',
320
320
  body: bodyStr,
321
321
  headers: {
322
- 'content-type': 'application/json'
323
- }
322
+ 'content-type': 'application/json',
323
+ },
324
324
  })
325
325
 
326
326
  const body = await resp.json()
@@ -337,8 +337,8 @@ describe('responses', () => {
337
337
  method: 'POST',
338
338
  body: bodyStr,
339
339
  headers: {
340
- 'content-type': 'application/json'
341
- }
340
+ 'content-type': 'application/json',
341
+ },
342
342
  })
343
343
 
344
344
  expect(resp.status).toBe(500)
@@ -352,8 +352,8 @@ describe('responses', () => {
352
352
  method: 'POST',
353
353
  body: bodyStr,
354
354
  headers: {
355
- 'content-type': 'application/json'
356
- }
355
+ 'content-type': 'application/json',
356
+ },
357
357
  })
358
358
 
359
359
  const body = await resp.json()
@@ -370,8 +370,8 @@ describe('responses', () => {
370
370
  method: 'POST',
371
371
  body: bodyStr,
372
372
  headers: {
373
- 'content-type': 'application/json'
374
- }
373
+ 'content-type': 'application/json',
374
+ },
375
375
  })
376
376
 
377
377
  expect(resp.status).toBe(500)
@@ -385,8 +385,8 @@ describe('responses', () => {
385
385
  method: 'POST',
386
386
  body: bodyStr,
387
387
  headers: {
388
- 'content-type': 'application/json'
389
- }
388
+ 'content-type': 'application/json',
389
+ },
390
390
  })
391
391
 
392
392
  const body = await resp.json()
@@ -403,8 +403,8 @@ describe('responses', () => {
403
403
  method: 'POST',
404
404
  body: bodyStr,
405
405
  headers: {
406
- 'content-type': 'application/json'
407
- }
406
+ 'content-type': 'application/json',
407
+ },
408
408
  })
409
409
 
410
410
  expect(resp.status).toBe(500)
@@ -417,8 +417,8 @@ describe('responses', () => {
417
417
  method: 'POST',
418
418
  body: bodyStr,
419
419
  headers: {
420
- 'content-type': 'text/plain'
421
- }
420
+ 'content-type': 'text/plain',
421
+ },
422
422
  })
423
423
 
424
424
  const reader = resp.body?.getReader()
@@ -438,7 +438,7 @@ describe('responses', () => {
438
438
 
439
439
  let resp = await fetch(`http://localhost:${port}/stream/ba`, {
440
440
  method: 'POST',
441
- body: bodyStr
441
+ body: bodyStr,
442
442
  })
443
443
 
444
444
  expect(resp.status).toBe(500)
@@ -451,8 +451,8 @@ describe('responses', () => {
451
451
  method: 'POST',
452
452
  body: bodyStr,
453
453
  headers: {
454
- 'content-type': 'text/plain'
455
- }
454
+ 'content-type': 'text/plain',
455
+ },
456
456
  })
457
457
 
458
458
  const reader = resp.body?.getReader()
@@ -474,8 +474,8 @@ describe('responses', () => {
474
474
  method: 'POST',
475
475
  body: bodyStr,
476
476
  headers: {
477
- 'content-type': 'application/json'
478
- }
477
+ 'content-type': 'application/json',
478
+ },
479
479
  })
480
480
 
481
481
  expect(resp.status).toBe(500)
@@ -27,7 +27,7 @@ export const schema_objectBase = {
27
27
  number: $T.number(),
28
28
  bool: $T.boolean(),
29
29
  any: $T.any(),
30
- optional: $T.optional($T.any())
30
+ optional: $T.optional($T.any()),
31
31
  }
32
32
  export const schema_object = {
33
33
  ...schema_objectBase,
@@ -35,7 +35,7 @@ export const schema_object = {
35
35
  array: $T.array(),
36
36
  null: $T.null(),
37
37
  nullable: $T.nullable($T.string()),
38
- nullish: $T.nullish($T.number())
38
+ nullish: $T.nullish($T.number()),
39
39
  }
40
40
 
41
41
  export const isAsyncIterator = (obj: any) => {
@@ -105,3 +105,5 @@ export const handleUrlFormStream = async (ctx: Context) => {
105
105
  }
106
106
  return { type: 'object', content: resp }
107
107
  }
108
+
109
+ export const EMPTY_BA_STR = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'