@jaredwray/mockhttp 0.0.1 → 0.1.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.
- package/README.md +5 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +896 -31
- package/package.json +23 -13
- package/dist/fastify-config.js +0 -12
- package/dist/routes/delete-route.js +0 -27
- package/dist/routes/get-route.js +0 -34
- package/dist/routes/http-methods/delete.js +0 -28
- package/dist/routes/http-methods/get.js +0 -35
- package/dist/routes/http-methods/index.js +0 -5
- package/dist/routes/http-methods/patch.js +0 -28
- package/dist/routes/http-methods/post.js +0 -28
- package/dist/routes/http-methods/put.js +0 -28
- package/dist/routes/index-route.js +0 -67
- package/dist/routes/ip-route.js +0 -25
- package/dist/routes/post-route.js +0 -27
- package/dist/routes/put-route.js +0 -27
- package/dist/routes/request-inspection/headers.js +0 -26
- package/dist/routes/request-inspection/index.js +0 -3
- package/dist/routes/request-inspection/ip.js +0 -26
- package/dist/routes/request-inspection/user-agent.js +0 -25
- package/dist/routes/status-codes/get.js +0 -29
- package/dist/routes/status-codes/index.js +0 -102
- package/dist/routes/status-route.js +0 -28
- package/dist/swagger.js +0 -34
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const statusSchema = {
|
|
2
|
-
description: 'Returns a response with the provided status code',
|
|
3
|
-
params: {
|
|
4
|
-
type: 'object',
|
|
5
|
-
properties: {
|
|
6
|
-
code: { type: 'string', description: 'HTTP status code to be returned' },
|
|
7
|
-
},
|
|
8
|
-
required: ['code'],
|
|
9
|
-
},
|
|
10
|
-
response: {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12
|
-
200: {
|
|
13
|
-
type: 'object',
|
|
14
|
-
properties: {
|
|
15
|
-
status: { type: 'string' },
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
export const statusRoute = (fastify) => {
|
|
21
|
-
fastify.get('/status/:code', { schema: statusSchema }, async (request, reply) => {
|
|
22
|
-
const { code } = request.params;
|
|
23
|
-
await reply.code(Number(code));
|
|
24
|
-
return {
|
|
25
|
-
status: `Response with status code ${code}`,
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
};
|
package/dist/swagger.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { fastifySwaggerUi } from '@fastify/swagger-ui';
|
|
2
|
-
export const fastifySwaggerConfig = {
|
|
3
|
-
swagger: {
|
|
4
|
-
info: {
|
|
5
|
-
title: 'Mock HTTP API',
|
|
6
|
-
description: 'A replacement for httpbin built using Fastify and Typescript',
|
|
7
|
-
version: '1.0.0',
|
|
8
|
-
},
|
|
9
|
-
consumes: ['application/json'],
|
|
10
|
-
produces: ['application/json'],
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export const registerSwaggerUi = async (fastify) => {
|
|
14
|
-
await fastify.register(fastifySwaggerUi, {
|
|
15
|
-
routePrefix: '/docs',
|
|
16
|
-
uiConfig: {
|
|
17
|
-
docExpansion: 'none',
|
|
18
|
-
deepLinking: false,
|
|
19
|
-
},
|
|
20
|
-
uiHooks: {
|
|
21
|
-
/* c8 ignore next 6 */
|
|
22
|
-
onRequest(_request, _reply, next) {
|
|
23
|
-
next();
|
|
24
|
-
},
|
|
25
|
-
preHandler(_request, _reply, next) {
|
|
26
|
-
next();
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
30
|
-
staticCSP: true,
|
|
31
|
-
transformSpecification: (swaggerObject, _request, _reply) => swaggerObject,
|
|
32
|
-
transformSpecificationClone: true,
|
|
33
|
-
});
|
|
34
|
-
};
|