@jaredwray/mockhttp 0.2.1 → 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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![public/logo.svg](public/logo.svg)
1
+ [![public/logo.svg](public/logo.svg)](https://mockhttp.org)
2
2
 
3
3
  [![tests](https://github.com/jaredwray/mockhttp/actions/workflows/tests.yaml/badge.svg)](https://github.com/jaredwray/mockhttp/actions/workflows/tests.yaml)
4
4
  [![GitHub license](https://img.shields.io/github/license/jaredwray/mockhttp)](https://github.com/jaredwray/mockhttp/blob/master/LICENSE)
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import fastifyStatic from "@fastify/static";
9
9
  import { fastifySwagger } from "@fastify/swagger";
10
10
  import fastifyHelmet from "@fastify/helmet";
11
11
 
12
- // src/routes/index-route.ts
12
+ // src/routes/index.ts
13
13
  var indexRoute = /* @__PURE__ */ __name((fastify2) => {
14
14
  fastify2.get("/", {
15
15
  schema: {
@@ -82,6 +82,35 @@ var indexRoute = /* @__PURE__ */ __name((fastify2) => {
82
82
  });
83
83
  }, "indexRoute");
84
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
+
85
114
  // src/fastify-config.ts
86
115
  var fastifyConfig = {
87
116
  logger: {
@@ -103,7 +132,7 @@ import { fastifySwaggerUi } from "@fastify/swagger-ui";
103
132
  // package.json
104
133
  var package_default = {
105
134
  name: "@jaredwray/mockhttp",
106
- version: "0.2.1",
135
+ version: "0.2.3",
107
136
  description: "Mock Http - Easy way to mock http with httpbin replacement",
108
137
  type: "module",
109
138
  main: "dist/index.js",
@@ -112,12 +141,13 @@ var package_default = {
112
141
  },
113
142
  scripts: {
114
143
  test: "xo --fix && vitest run --coverage",
115
- dev: "xo --fix && npx tsx src/index.ts --watch",
144
+ dev: "xo --fix && tsx src/index.ts --watch",
116
145
  build: "rimraf ./dist && tsup src/index.ts --format esm --dts --clean",
117
146
  "docker:build": "docker build -t jaredwray/mockhttp .",
118
147
  "docker:run": "docker run -p 3000:3000 jaredwray/mockhttp",
119
148
  "docker:push": "docker push jaredwray/mockhttp",
120
149
  "docker:stop": 'docker stop $(docker ps -a -q --filter ancestor=jaredwray/mockhttp --format="{{.ID}}")',
150
+ "docker:readme": "tsx ./scripts/create-docker-readme.ts",
121
151
  prepare: "npm run build",
122
152
  start: "node dist/index.js"
123
153
  },
@@ -138,7 +168,7 @@ var package_default = {
138
168
  },
139
169
  homepage: "https://github.com/jaredwray/mockhttp#readme",
140
170
  devDependencies: {
141
- "@swc/core": "^1.10.1",
171
+ "@swc/core": "^1.10.4",
142
172
  "@types/html-escaper": "^3.0.2",
143
173
  "@vitest/coverage-v8": "^2.1.8",
144
174
  rimraf: "^6.0.1",
@@ -153,10 +183,10 @@ var package_default = {
153
183
  "@fastify/static": "^8.0.3",
154
184
  "@fastify/swagger": "^9.4.0",
155
185
  "@fastify/swagger-ui": "^5.2.0",
156
- "@scalar/api-reference": "^1.25.82",
157
- fastify: "^5.1.0",
186
+ "@scalar/api-reference": "^1.25.99",
187
+ fastify: "^5.2.0",
158
188
  "html-escaper": "^3.0.3",
159
- pino: "^9.5.0",
189
+ pino: "^9.6.0",
160
190
  "pino-pretty": "^13.0.0"
161
191
  },
162
192
  files: [
@@ -1058,6 +1088,7 @@ await fastify.register(fastifyHelmet);
1058
1088
  await fastify.register(fastifySwagger, fastifySwaggerConfig);
1059
1089
  await registerSwaggerUi(fastify);
1060
1090
  await fastify.register(indexRoute);
1091
+ await fastify.register(sitemapRoute);
1061
1092
  await fastify.register(getRoute);
1062
1093
  await fastify.register(postRoute);
1063
1094
  await fastify.register(deleteRoute);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jaredwray/mockhttp",
3
- "version": "0.2.1",
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,12 +9,13 @@
9
9
  },
10
10
  "scripts": {
11
11
  "test": "xo --fix && vitest run --coverage",
12
- "dev": "xo --fix && npx tsx src/index.ts --watch",
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",
16
16
  "docker:push": "docker push jaredwray/mockhttp",
17
17
  "docker:stop": "docker stop $(docker ps -a -q --filter ancestor=jaredwray/mockhttp --format=\"{{.ID}}\")",
18
+ "docker:readme": "tsx ./scripts/create-docker-readme.ts",
18
19
  "prepare": "npm run build",
19
20
  "start": "node dist/index.js"
20
21
  },
@@ -35,7 +36,7 @@
35
36
  },
36
37
  "homepage": "https://github.com/jaredwray/mockhttp#readme",
37
38
  "devDependencies": {
38
- "@swc/core": "^1.10.1",
39
+ "@swc/core": "^1.10.4",
39
40
  "@types/html-escaper": "^3.0.2",
40
41
  "@vitest/coverage-v8": "^2.1.8",
41
42
  "rimraf": "^6.0.1",
@@ -50,10 +51,10 @@
50
51
  "@fastify/static": "^8.0.3",
51
52
  "@fastify/swagger": "^9.4.0",
52
53
  "@fastify/swagger-ui": "^5.2.0",
53
- "@scalar/api-reference": "^1.25.82",
54
- "fastify": "^5.1.0",
54
+ "@scalar/api-reference": "^1.25.99",
55
+ "fastify": "^5.2.0",
55
56
  "html-escaper": "^3.0.3",
56
- "pino": "^9.5.0",
57
+ "pino": "^9.6.0",
57
58
  "pino-pretty": "^13.0.0"
58
59
  },
59
60
  "files": [
@@ -0,0 +1,2 @@
1
+ User-agent: *
2
+ Allow: /