@jaredwray/mockhttp 0.7.0 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.js +185 -34
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -36,7 +36,6 @@ var anythingSchema = {
36
36
  "Anything"
37
37
  ],
38
38
  response: {
39
- // eslint-disable-next-line @typescript-eslint/naming-convention
40
39
  200: {
41
40
  type: "object",
42
41
  properties: {
@@ -190,7 +189,6 @@ var basicAuthSchema = {
190
189
  ]
191
190
  },
192
191
  response: {
193
- // eslint-disable-next-line @typescript-eslint/naming-convention
194
192
  200: {
195
193
  type: "object",
196
194
  properties: {
@@ -206,7 +204,6 @@ var basicAuthSchema = {
206
204
  "user"
207
205
  ]
208
206
  },
209
- // eslint-disable-next-line @typescript-eslint/naming-convention
210
207
  401: {
211
208
  type: "object",
212
209
  properties: {
@@ -271,7 +268,6 @@ var bearerAuthSchema = {
271
268
  }
272
269
  },
273
270
  response: {
274
- // eslint-disable-next-line @typescript-eslint/naming-convention
275
271
  200: {
276
272
  type: "object",
277
273
  properties: {
@@ -287,7 +283,6 @@ var bearerAuthSchema = {
287
283
  "token"
288
284
  ]
289
285
  },
290
- // eslint-disable-next-line @typescript-eslint/naming-convention
291
286
  401: {
292
287
  type: "object",
293
288
  properties: {
@@ -426,7 +421,6 @@ var digestAuthSchema = {
426
421
  algorithm: {
427
422
  type: "string"
428
423
  },
429
- // eslint-disable-next-line @typescript-eslint/naming-convention
430
424
  stale_after: {
431
425
  type: "string"
432
426
  }
@@ -599,7 +593,6 @@ var cookiesDeleteSchema = {
599
593
  additionalProperties: false
600
594
  },
601
595
  response: {
602
- // eslint-disable-next-line @typescript-eslint/naming-convention
603
596
  204: {
604
597
  type: "null"
605
598
  }
@@ -624,7 +617,6 @@ var getCookiesRouteSchema = {
624
617
  "Cookies"
625
618
  ],
626
619
  response: {
627
- // eslint-disable-next-line @typescript-eslint/naming-convention
628
620
  200: {
629
621
  type: "object",
630
622
  properties: {
@@ -679,7 +671,6 @@ var postCookieRouteSchema = {
679
671
  additionalProperties: false
680
672
  },
681
673
  response: {
682
- // eslint-disable-next-line @typescript-eslint/naming-convention
683
674
  200: {
684
675
  type: "object",
685
676
  properties: {
@@ -728,7 +719,6 @@ var deleteSchema = {
728
719
  description: "The body of the DELETE request"
729
720
  },
730
721
  response: {
731
- // eslint-disable-next-line @typescript-eslint/naming-convention
732
722
  200: {
733
723
  type: "object",
734
724
  properties: {
@@ -783,7 +773,6 @@ var getSchema = {
783
773
  description: "Headers sent in the request"
784
774
  },
785
775
  response: {
786
- // eslint-disable-next-line @typescript-eslint/naming-convention
787
776
  200: {
788
777
  type: "object",
789
778
  properties: {
@@ -833,7 +822,6 @@ var patchSchema = {
833
822
  description: "The body of the PATCH request"
834
823
  },
835
824
  response: {
836
- // eslint-disable-next-line @typescript-eslint/naming-convention
837
825
  200: {
838
826
  type: "object",
839
827
  properties: {
@@ -881,7 +869,6 @@ var postSchema = {
881
869
  description: "The body of the POST request"
882
870
  },
883
871
  response: {
884
- // eslint-disable-next-line @typescript-eslint/naming-convention
885
872
  200: {
886
873
  type: "object",
887
874
  properties: {
@@ -929,7 +916,6 @@ var putSchema = {
929
916
  description: "The body of the PUT request"
930
917
  },
931
918
  response: {
932
- // eslint-disable-next-line @typescript-eslint/naming-convention
933
919
  200: {
934
920
  type: "object",
935
921
  properties: {
@@ -1071,7 +1057,6 @@ var absoluteRedirectSchema = {
1071
1057
  ]
1072
1058
  },
1073
1059
  response: {
1074
- // eslint-disable-next-line @typescript-eslint/naming-convention
1075
1060
  302: {
1076
1061
  type: "string"
1077
1062
  }
@@ -1116,7 +1101,6 @@ var redirectToSchema = {
1116
1101
  format: "uri",
1117
1102
  description: "The URL to redirect to"
1118
1103
  },
1119
- // eslint-disable-next-line @typescript-eslint/naming-convention
1120
1104
  status_code: {
1121
1105
  type: "string",
1122
1106
  pattern: "^[1-5][0-9][0-9]$",
@@ -1182,7 +1166,6 @@ var relativeRedirectSchema = {
1182
1166
  ]
1183
1167
  },
1184
1168
  response: {
1185
- // eslint-disable-next-line @typescript-eslint/naming-convention
1186
1169
  302: {
1187
1170
  type: "string"
1188
1171
  }
@@ -1218,7 +1201,6 @@ var headersSchema = {
1218
1201
  "Request Inspection"
1219
1202
  ],
1220
1203
  response: {
1221
- // eslint-disable-next-line @typescript-eslint/naming-convention
1222
1204
  200: {
1223
1205
  type: "object",
1224
1206
  properties: {
@@ -1254,7 +1236,6 @@ var ipSchema = {
1254
1236
  "Request Inspection"
1255
1237
  ],
1256
1238
  response: {
1257
- // eslint-disable-next-line @typescript-eslint/naming-convention
1258
1239
  200: {
1259
1240
  type: "object",
1260
1241
  properties: {
@@ -1290,7 +1271,6 @@ var userAgentSchema = {
1290
1271
  "Request Inspection"
1291
1272
  ],
1292
1273
  response: {
1293
- // eslint-disable-next-line @typescript-eslint/naming-convention
1294
1274
  200: {
1295
1275
  type: "object",
1296
1276
  properties: {
@@ -1323,12 +1303,10 @@ var cacheGetSchema = {
1323
1303
  "Response Inspection"
1324
1304
  ],
1325
1305
  response: {
1326
- // eslint-disable-next-line @typescript-eslint/naming-convention
1327
1306
  200: {
1328
1307
  type: "string",
1329
1308
  description: "The cached content or resource."
1330
1309
  },
1331
- // eslint-disable-next-line @typescript-eslint/naming-convention
1332
1310
  304: {
1333
1311
  type: "null",
1334
1312
  description: "Indicates the resource has not been modified."
@@ -1353,7 +1331,6 @@ var cacheSetSchema = {
1353
1331
  ]
1354
1332
  },
1355
1333
  response: {
1356
- // eslint-disable-next-line @typescript-eslint/naming-convention
1357
1334
  200: {
1358
1335
  type: "string",
1359
1336
  description: "Confirmation message for setting cache."
@@ -1399,17 +1376,14 @@ var etagSchema = {
1399
1376
  ]
1400
1377
  },
1401
1378
  response: {
1402
- // eslint-disable-next-line @typescript-eslint/naming-convention
1403
1379
  200: {
1404
1380
  type: "string",
1405
1381
  description: "Resource content for matching ETag."
1406
1382
  },
1407
- // eslint-disable-next-line @typescript-eslint/naming-convention
1408
1383
  304: {
1409
1384
  type: "null",
1410
1385
  description: "Indicates the resource has not been modified."
1411
1386
  },
1412
- // eslint-disable-next-line @typescript-eslint/naming-convention
1413
1387
  412: {
1414
1388
  type: "null",
1415
1389
  description: "Indicates a precondition failed due to mismatched ETag."
@@ -1435,6 +1409,186 @@ var etagRoutes = /* @__PURE__ */ __name((fastify) => {
1435
1409
  });
1436
1410
  }, "etagRoutes");
1437
1411
 
1412
+ // src/routes/response-inspection/plain.ts
1413
+ var plainSchema = {
1414
+ description: "Returns random plain text content",
1415
+ tags: [
1416
+ "Response Inspection"
1417
+ ],
1418
+ // @ts-expect-error
1419
+ response: {
1420
+ 200: {
1421
+ type: "string",
1422
+ description: "Random plain text content"
1423
+ }
1424
+ }
1425
+ };
1426
+ var textSchema = {
1427
+ description: "Returns random text content",
1428
+ tags: [
1429
+ "Response Inspection"
1430
+ ],
1431
+ // @ts-expect-error
1432
+ response: {
1433
+ 200: {
1434
+ type: "string",
1435
+ description: "Random text content"
1436
+ }
1437
+ }
1438
+ };
1439
+ var htmlSchema = {
1440
+ description: "Returns random HTML content",
1441
+ tags: [
1442
+ "Response Inspection"
1443
+ ],
1444
+ // @ts-expect-error
1445
+ response: {
1446
+ 200: {
1447
+ type: "string",
1448
+ description: "Random HTML content"
1449
+ }
1450
+ }
1451
+ };
1452
+ var randomTexts = [
1453
+ "The quick brown fox jumps over the lazy dog.",
1454
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
1455
+ "To be or not to be, that is the question.",
1456
+ "All work and no play makes Jack a dull boy.",
1457
+ "The only way to do great work is to love what you do.",
1458
+ "In the beginning was the Word, and the Word was with God.",
1459
+ "Once upon a time in a galaxy far, far away...",
1460
+ "It was the best of times, it was the worst of times.",
1461
+ "The journey of a thousand miles begins with a single step.",
1462
+ "Knowledge is power. France is bacon."
1463
+ ];
1464
+ var randomHtmlContent = [
1465
+ `<!DOCTYPE html>
1466
+ <html lang="en">
1467
+ <head>
1468
+ <title>Sample Page</title>
1469
+ </head>
1470
+ <body>
1471
+ <h1>Welcome to MockHTTP</h1>
1472
+ <p>This is a sample HTML page with random content.</p>
1473
+ </body>
1474
+ </html>`,
1475
+ `<!DOCTYPE html>
1476
+ <html>
1477
+ <head>
1478
+ <meta charset="UTF-8">
1479
+ <title>Test Document</title>
1480
+ </head>
1481
+ <body>
1482
+ <header>
1483
+ <h1>Test Page</h1>
1484
+ <nav>
1485
+ <ul>
1486
+ <li><a href="#">Home</a></li>
1487
+ <li><a href="#">About</a></li>
1488
+ <li><a href="#">Contact</a></li>
1489
+ </ul>
1490
+ </nav>
1491
+ </header>
1492
+ <main>
1493
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
1494
+ </main>
1495
+ </body>
1496
+ </html>`,
1497
+ `<!DOCTYPE html>
1498
+ <html lang="en">
1499
+ <head>
1500
+ <title>Article Page</title>
1501
+ <style>
1502
+ body { font-family: Arial, sans-serif; }
1503
+ article { max-width: 800px; margin: 0 auto; }
1504
+ </style>
1505
+ </head>
1506
+ <body>
1507
+ <article>
1508
+ <h1>The Journey Begins</h1>
1509
+ <p>Once upon a time in a digital world...</p>
1510
+ <blockquote>
1511
+ "The only way to do great work is to love what you do."
1512
+ </blockquote>
1513
+ </article>
1514
+ </body>
1515
+ </html>`,
1516
+ `<!DOCTYPE html>
1517
+ <html>
1518
+ <head>
1519
+ <title>Form Example</title>
1520
+ </head>
1521
+ <body>
1522
+ <h2>Contact Form</h2>
1523
+ <form action="/submit" method="post">
1524
+ <label for="name">Name:</label>
1525
+ <input type="text" id="name" name="name" required>
1526
+ <br>
1527
+ <label for="email">Email:</label>
1528
+ <input type="email" id="email" name="email" required>
1529
+ <br>
1530
+ <button type="submit">Submit</button>
1531
+ </form>
1532
+ </body>
1533
+ </html>`,
1534
+ `<!DOCTYPE html>
1535
+ <html lang="en">
1536
+ <head>
1537
+ <meta charset="UTF-8">
1538
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1539
+ <title>Responsive Page</title>
1540
+ </head>
1541
+ <body>
1542
+ <div class="container">
1543
+ <h1>Responsive Design</h1>
1544
+ <p>This page adapts to different screen sizes.</p>
1545
+ <img src="placeholder.jpg" alt="Placeholder" style="max-width: 100%; height: auto;">
1546
+ </div>
1547
+ </body>
1548
+ </html>`
1549
+ ];
1550
+ var plainRoute = /* @__PURE__ */ __name((fastify) => {
1551
+ fastify.get(
1552
+ "/plain",
1553
+ {
1554
+ schema: plainSchema
1555
+ },
1556
+ // biome-ignore lint/suspicious/noExplicitAny: reply
1557
+ async (_request, reply) => {
1558
+ const randomIndex = Math.floor(Math.random() * randomTexts.length);
1559
+ const text = randomTexts[randomIndex];
1560
+ reply.type("text/plain");
1561
+ return text;
1562
+ }
1563
+ );
1564
+ fastify.get(
1565
+ "/text",
1566
+ {
1567
+ schema: textSchema
1568
+ },
1569
+ // biome-ignore lint/suspicious/noExplicitAny: reply
1570
+ async (_request, reply) => {
1571
+ const randomIndex = Math.floor(Math.random() * randomTexts.length);
1572
+ const text = randomTexts[randomIndex];
1573
+ reply.type("text/plain");
1574
+ return text;
1575
+ }
1576
+ );
1577
+ fastify.get(
1578
+ "/html",
1579
+ {
1580
+ schema: htmlSchema
1581
+ },
1582
+ // biome-ignore lint/suspicious/noExplicitAny: reply
1583
+ async (_request, reply) => {
1584
+ const randomIndex = Math.floor(Math.random() * randomHtmlContent.length);
1585
+ const html = randomHtmlContent[randomIndex];
1586
+ reply.type("text/html");
1587
+ return html;
1588
+ }
1589
+ );
1590
+ }, "plainRoute");
1591
+
1438
1592
  // src/routes/response-inspection/response-headers.ts
1439
1593
  import { escape as escapeHtml } from "html-escaper";
1440
1594
  var responseHeadersSchema = {
@@ -1448,7 +1602,6 @@ var responseHeadersSchema = {
1448
1602
  description: "Freeform query string parameters to be added as response headers."
1449
1603
  },
1450
1604
  response: {
1451
- // eslint-disable-next-line @typescript-eslint/naming-convention
1452
1605
  200: {
1453
1606
  type: "object",
1454
1607
  additionalProperties: true,
@@ -1792,7 +1945,6 @@ var statusSchema = {
1792
1945
  }
1793
1946
  },
1794
1947
  response: {
1795
- // eslint-disable-next-line @typescript-eslint/naming-convention
1796
1948
  200: {
1797
1949
  type: "object",
1798
1950
  properties: {
@@ -1836,7 +1988,7 @@ import { fastifySwaggerUi } from "@fastify/swagger-ui";
1836
1988
  // package.json
1837
1989
  var package_default = {
1838
1990
  name: "@jaredwray/mockhttp",
1839
- version: "0.7.0",
1991
+ version: "0.8.0",
1840
1992
  description: "Mock Http - Easy way to mock http with httpbin replacement",
1841
1993
  type: "module",
1842
1994
  main: "dist/index.js",
@@ -1877,12 +2029,12 @@ var package_default = {
1877
2029
  homepage: "https://github.com/jaredwray/mockhttp#readme",
1878
2030
  devDependencies: {
1879
2031
  "@biomejs/biome": "^2.2.2",
1880
- "@swc/core": "^1.13.4",
2032
+ "@swc/core": "^1.13.5",
1881
2033
  "@types/html-escaper": "^3.0.4",
1882
2034
  "@vitest/coverage-v8": "^3.2.4",
1883
2035
  rimraf: "^6.0.1",
1884
2036
  tsup: "^8.5.0",
1885
- tsx: "^4.20.4",
2037
+ tsx: "^4.20.5",
1886
2038
  typescript: "^5.9.2",
1887
2039
  vitest: "^3.2.4"
1888
2040
  },
@@ -1892,7 +2044,7 @@ var package_default = {
1892
2044
  "@fastify/static": "^8.2.0",
1893
2045
  "@fastify/swagger": "^9.5.1",
1894
2046
  "@fastify/swagger-ui": "^5.2.3",
1895
- "@scalar/api-reference": "^1.34.4",
2047
+ "@scalar/api-reference": "^1.34.6",
1896
2048
  "detect-port": "^2.1.0",
1897
2049
  fastify: "^5.5.0",
1898
2050
  hookified: "^1.12.0",
@@ -1957,7 +2109,6 @@ var registerSwaggerUi = /* @__PURE__ */ __name(async (fastify) => {
1957
2109
  next();
1958
2110
  }
1959
2111
  },
1960
- // eslint-disable-next-line @typescript-eslint/naming-convention
1961
2112
  staticCSP: true,
1962
2113
  transformSpecification: /* @__PURE__ */ __name((swaggerObject, _request, _reply) => swaggerObject, "transformSpecification"),
1963
2114
  transformSpecificationClone: true
@@ -1984,7 +2135,6 @@ var MockHttp = class extends Hookified {
1984
2135
  anything: true,
1985
2136
  auth: true
1986
2137
  };
1987
- // eslint-disable-next-line new-cap
1988
2138
  _server = Fastify();
1989
2139
  constructor(options) {
1990
2140
  super(options?.hookOptions);
@@ -2224,6 +2374,7 @@ var MockHttp = class extends Hookified {
2224
2374
  const fastify = fastifyInstance ?? this._server;
2225
2375
  await fastify.register(cacheRoutes);
2226
2376
  await fastify.register(etagRoutes);
2377
+ await fastify.register(plainRoute);
2227
2378
  await fastify.register(responseHeadersRoutes);
2228
2379
  }
2229
2380
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jaredwray/mockhttp",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Mock Http - Easy way to mock http with httpbin replacement",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,12 +41,12 @@
41
41
  "homepage": "https://github.com/jaredwray/mockhttp#readme",
42
42
  "devDependencies": {
43
43
  "@biomejs/biome": "^2.2.2",
44
- "@swc/core": "^1.13.4",
44
+ "@swc/core": "^1.13.5",
45
45
  "@types/html-escaper": "^3.0.4",
46
46
  "@vitest/coverage-v8": "^3.2.4",
47
47
  "rimraf": "^6.0.1",
48
48
  "tsup": "^8.5.0",
49
- "tsx": "^4.20.4",
49
+ "tsx": "^4.20.5",
50
50
  "typescript": "^5.9.2",
51
51
  "vitest": "^3.2.4"
52
52
  },
@@ -56,7 +56,7 @@
56
56
  "@fastify/static": "^8.2.0",
57
57
  "@fastify/swagger": "^9.5.1",
58
58
  "@fastify/swagger-ui": "^5.2.3",
59
- "@scalar/api-reference": "^1.34.4",
59
+ "@scalar/api-reference": "^1.34.6",
60
60
  "detect-port": "^2.1.0",
61
61
  "fastify": "^5.5.0",
62
62
  "hookified": "^1.12.0",