@jaredwray/mockhttp 0.2.2 → 0.2.3
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/index.js +37 -12
- package/package.json +6 -7
- package/public/robots.txt +2 -0
package/dist/index.js
CHANGED
|
@@ -8,9 +8,8 @@ import Fastify from "fastify";
|
|
|
8
8
|
import fastifyStatic from "@fastify/static";
|
|
9
9
|
import { fastifySwagger } from "@fastify/swagger";
|
|
10
10
|
import fastifyHelmet from "@fastify/helmet";
|
|
11
|
-
import fastifyCors from "@fastify/cors";
|
|
12
11
|
|
|
13
|
-
// src/routes/index
|
|
12
|
+
// src/routes/index.ts
|
|
14
13
|
var indexRoute = /* @__PURE__ */ __name((fastify2) => {
|
|
15
14
|
fastify2.get("/", {
|
|
16
15
|
schema: {
|
|
@@ -83,6 +82,35 @@ var indexRoute = /* @__PURE__ */ __name((fastify2) => {
|
|
|
83
82
|
});
|
|
84
83
|
}, "indexRoute");
|
|
85
84
|
|
|
85
|
+
// src/routes/sitemap.ts
|
|
86
|
+
var sitemapRoute = /* @__PURE__ */ __name((fastify2) => {
|
|
87
|
+
fastify2.get("/sitemap.xml", {
|
|
88
|
+
schema: {
|
|
89
|
+
hide: true
|
|
90
|
+
}
|
|
91
|
+
}, async (_request, reply) => {
|
|
92
|
+
try {
|
|
93
|
+
const host = _request.headers.host ?? "mockhttp.org";
|
|
94
|
+
const isSecure = _request.headers["x-forwarded-proto"]?.includes("https");
|
|
95
|
+
const protocol = isSecure ? "https" : "http";
|
|
96
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
97
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
98
|
+
<url>
|
|
99
|
+
<loc>${protocol}://${host}/</loc>
|
|
100
|
+
<changefreq>monthly</changefreq>
|
|
101
|
+
<priority>1.0</priority>
|
|
102
|
+
</url>
|
|
103
|
+
</urlset>`;
|
|
104
|
+
await reply.type("text/xml").send(xml);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
fastify2.log.error(error);
|
|
107
|
+
await reply.status(500).send({
|
|
108
|
+
error: "Internal Server Error"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}, "sitemapRoute");
|
|
113
|
+
|
|
86
114
|
// src/fastify-config.ts
|
|
87
115
|
var fastifyConfig = {
|
|
88
116
|
logger: {
|
|
@@ -104,7 +132,7 @@ import { fastifySwaggerUi } from "@fastify/swagger-ui";
|
|
|
104
132
|
// package.json
|
|
105
133
|
var package_default = {
|
|
106
134
|
name: "@jaredwray/mockhttp",
|
|
107
|
-
version: "0.2.
|
|
135
|
+
version: "0.2.3",
|
|
108
136
|
description: "Mock Http - Easy way to mock http with httpbin replacement",
|
|
109
137
|
type: "module",
|
|
110
138
|
main: "dist/index.js",
|
|
@@ -113,7 +141,7 @@ var package_default = {
|
|
|
113
141
|
},
|
|
114
142
|
scripts: {
|
|
115
143
|
test: "xo --fix && vitest run --coverage",
|
|
116
|
-
dev: "xo --fix &&
|
|
144
|
+
dev: "xo --fix && tsx src/index.ts --watch",
|
|
117
145
|
build: "rimraf ./dist && tsup src/index.ts --format esm --dts --clean",
|
|
118
146
|
"docker:build": "docker build -t jaredwray/mockhttp .",
|
|
119
147
|
"docker:run": "docker run -p 3000:3000 jaredwray/mockhttp",
|
|
@@ -140,7 +168,7 @@ var package_default = {
|
|
|
140
168
|
},
|
|
141
169
|
homepage: "https://github.com/jaredwray/mockhttp#readme",
|
|
142
170
|
devDependencies: {
|
|
143
|
-
"@swc/core": "^1.10.
|
|
171
|
+
"@swc/core": "^1.10.4",
|
|
144
172
|
"@types/html-escaper": "^3.0.2",
|
|
145
173
|
"@vitest/coverage-v8": "^2.1.8",
|
|
146
174
|
rimraf: "^6.0.1",
|
|
@@ -151,15 +179,14 @@ var package_default = {
|
|
|
151
179
|
xo: "^0.60.0"
|
|
152
180
|
},
|
|
153
181
|
dependencies: {
|
|
154
|
-
"@fastify/cors": "^10.0.1",
|
|
155
182
|
"@fastify/helmet": "^13.0.0",
|
|
156
183
|
"@fastify/static": "^8.0.3",
|
|
157
184
|
"@fastify/swagger": "^9.4.0",
|
|
158
185
|
"@fastify/swagger-ui": "^5.2.0",
|
|
159
|
-
"@scalar/api-reference": "^1.25.
|
|
160
|
-
fastify: "^5.
|
|
186
|
+
"@scalar/api-reference": "^1.25.99",
|
|
187
|
+
fastify: "^5.2.0",
|
|
161
188
|
"html-escaper": "^3.0.3",
|
|
162
|
-
pino: "^9.
|
|
189
|
+
pino: "^9.6.0",
|
|
163
190
|
"pino-pretty": "^13.0.0"
|
|
164
191
|
},
|
|
165
192
|
files: [
|
|
@@ -1057,13 +1084,11 @@ await fastify.register(fastifyStatic, {
|
|
|
1057
1084
|
root: path.resolve("./public"),
|
|
1058
1085
|
decorateReply: false
|
|
1059
1086
|
});
|
|
1060
|
-
await fastify.register(fastifyCors, {
|
|
1061
|
-
origin: "*"
|
|
1062
|
-
});
|
|
1063
1087
|
await fastify.register(fastifyHelmet);
|
|
1064
1088
|
await fastify.register(fastifySwagger, fastifySwaggerConfig);
|
|
1065
1089
|
await registerSwaggerUi(fastify);
|
|
1066
1090
|
await fastify.register(indexRoute);
|
|
1091
|
+
await fastify.register(sitemapRoute);
|
|
1067
1092
|
await fastify.register(getRoute);
|
|
1068
1093
|
await fastify.register(postRoute);
|
|
1069
1094
|
await fastify.register(deleteRoute);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaredwray/mockhttp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Mock Http - Easy way to mock http with httpbin replacement",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "xo --fix && vitest run --coverage",
|
|
12
|
-
"dev": "xo --fix &&
|
|
12
|
+
"dev": "xo --fix && tsx src/index.ts --watch",
|
|
13
13
|
"build": "rimraf ./dist && tsup src/index.ts --format esm --dts --clean",
|
|
14
14
|
"docker:build": "docker build -t jaredwray/mockhttp .",
|
|
15
15
|
"docker:run": "docker run -p 3000:3000 jaredwray/mockhttp",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/jaredwray/mockhttp#readme",
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@swc/core": "^1.10.
|
|
39
|
+
"@swc/core": "^1.10.4",
|
|
40
40
|
"@types/html-escaper": "^3.0.2",
|
|
41
41
|
"@vitest/coverage-v8": "^2.1.8",
|
|
42
42
|
"rimraf": "^6.0.1",
|
|
@@ -47,15 +47,14 @@
|
|
|
47
47
|
"xo": "^0.60.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@fastify/cors": "^10.0.1",
|
|
51
50
|
"@fastify/helmet": "^13.0.0",
|
|
52
51
|
"@fastify/static": "^8.0.3",
|
|
53
52
|
"@fastify/swagger": "^9.4.0",
|
|
54
53
|
"@fastify/swagger-ui": "^5.2.0",
|
|
55
|
-
"@scalar/api-reference": "^1.25.
|
|
56
|
-
"fastify": "^5.
|
|
54
|
+
"@scalar/api-reference": "^1.25.99",
|
|
55
|
+
"fastify": "^5.2.0",
|
|
57
56
|
"html-escaper": "^3.0.3",
|
|
58
|
-
"pino": "^9.
|
|
57
|
+
"pino": "^9.6.0",
|
|
59
58
|
"pino-pretty": "^13.0.0"
|
|
60
59
|
},
|
|
61
60
|
"files": [
|