@mcphero/fastify 1.1.6
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/.turbo/turbo-build.log +18 -0
- package/.turbo/turbo-check.log +12 -0
- package/.turbo/turbo-prepack.log +26 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +69 -0
- package/build/index.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @mcphero/fastify@1.1.6 build /Users/atomic/projects/ai/mcphero/packages/fastify
|
|
4
|
+
> tsup
|
|
5
|
+
|
|
6
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
7
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v8.5.1
|
|
9
|
+
[34mCLI[39m Using tsup config: /Users/atomic/projects/ai/mcphero/packages/fastify/tsup.config.ts
|
|
10
|
+
[34mCLI[39m Target: es2022
|
|
11
|
+
[34mCLI[39m Cleaning output folder
|
|
12
|
+
[34mESM[39m Build start
|
|
13
|
+
[32mESM[39m [1mbuild/index.js [22m[32m2.06 KB[39m
|
|
14
|
+
[32mESM[39m [1mbuild/index.js.map [22m[32m3.88 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 7ms
|
|
16
|
+
DTS Build start
|
|
17
|
+
DTS ⚡️ Build success in 825ms
|
|
18
|
+
DTS build/index.d.ts 384.00 B
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
> @mcphero/fastify@1.1.6 check /Users/atomic/projects/ai/mcphero/packages/fastify
|
|
3
|
+
> pnpm lint && pnpm typecheck
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> @mcphero/fastify@1.1.6 lint /Users/atomic/projects/ai/mcphero/packages/fastify
|
|
7
|
+
> eslint
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
> @mcphero/fastify@1.1.6 typecheck /Users/atomic/projects/ai/mcphero/packages/fastify
|
|
11
|
+
> tsc --noEmit
|
|
12
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @mcphero/fastify@1.1.6 prepack /Users/atomic/projects/ai/mcphero/packages/fastify
|
|
4
|
+
> pnpm clean && pnpm build
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
> @mcphero/fastify@1.1.6 clean /Users/atomic/projects/ai/mcphero/packages/fastify
|
|
8
|
+
> rimraf build
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
> @mcphero/fastify@1.1.6 build /Users/atomic/projects/ai/mcphero/packages/fastify
|
|
12
|
+
> tsup
|
|
13
|
+
|
|
14
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
15
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
16
|
+
[34mCLI[39m tsup v8.5.1
|
|
17
|
+
[34mCLI[39m Using tsup config: /Users/atomic/projects/ai/mcphero/packages/fastify/tsup.config.ts
|
|
18
|
+
[34mCLI[39m Target: es2022
|
|
19
|
+
[34mCLI[39m Cleaning output folder
|
|
20
|
+
[34mESM[39m Build start
|
|
21
|
+
[32mESM[39m [1mbuild/index.js [22m[32m2.06 KB[39m
|
|
22
|
+
[32mESM[39m [1mbuild/index.js.map [22m[32m3.88 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 8ms
|
|
24
|
+
DTS Build start
|
|
25
|
+
DTS ⚡️ Build success in 1051ms
|
|
26
|
+
DTS build/index.d.ts 384.00 B
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdapterFactory } from '@mcphero/core';
|
|
2
|
+
import { FastifyHttpOptions, FastifyBaseLogger } from 'fastify';
|
|
3
|
+
import { Server } from 'http';
|
|
4
|
+
|
|
5
|
+
interface FastifyAdapterOptions extends FastifyHttpOptions<Server, FastifyBaseLogger> {
|
|
6
|
+
host?: string;
|
|
7
|
+
port?: number;
|
|
8
|
+
}
|
|
9
|
+
declare const fastify: AdapterFactory<FastifyAdapterOptions>;
|
|
10
|
+
|
|
11
|
+
export { type FastifyAdapterOptions, fastify };
|
package/build/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/adapter/fastify.ts
|
|
2
|
+
import { buildLogLevels } from "@mcphero/logger";
|
|
3
|
+
import { fastify as fastifyInstance } from "fastify";
|
|
4
|
+
var PINO_LEVEL_MAP = {
|
|
5
|
+
emergency: "fatal",
|
|
6
|
+
alert: "fatal",
|
|
7
|
+
critical: "fatal",
|
|
8
|
+
error: "error",
|
|
9
|
+
warning: "warn",
|
|
10
|
+
notice: "debug",
|
|
11
|
+
info: "info",
|
|
12
|
+
debug: "debug"
|
|
13
|
+
};
|
|
14
|
+
var fastify = ({ host, port, ...fastifyOptions }) => {
|
|
15
|
+
const instance = fastifyInstance(fastifyOptions);
|
|
16
|
+
return (options, baseContext) => {
|
|
17
|
+
const context = baseContext.fork({ adapter: "fastify" });
|
|
18
|
+
return {
|
|
19
|
+
context,
|
|
20
|
+
start: async (actions) => {
|
|
21
|
+
await instance.register(import("@fastify/swagger"), {
|
|
22
|
+
openapi: {
|
|
23
|
+
info: {
|
|
24
|
+
title: options.name,
|
|
25
|
+
description: options.description,
|
|
26
|
+
version: options.version
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
await instance.register(import("@scalar/fastify-api-reference"), { routePrefix: "/" });
|
|
31
|
+
for (const action of actions) {
|
|
32
|
+
const schema = action.input.toJSONSchema();
|
|
33
|
+
instance.post(`/${action.name}`, {
|
|
34
|
+
schema: {
|
|
35
|
+
description: action.description,
|
|
36
|
+
body: {
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: schema.properties,
|
|
39
|
+
required: schema.required
|
|
40
|
+
},
|
|
41
|
+
response: {
|
|
42
|
+
200: { description: "Successful response" }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, (request) => {
|
|
46
|
+
const logger = {
|
|
47
|
+
...buildLogLevels((level, data) => {
|
|
48
|
+
const pinoLevel = PINO_LEVEL_MAP[level] ?? "info";
|
|
49
|
+
instance.log[pinoLevel](data);
|
|
50
|
+
}),
|
|
51
|
+
progress: ({ progress, total, message }) => {
|
|
52
|
+
instance.log.trace({ progress, total }, message);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return action.run(request.body, context.fork({ logger, request }));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
await instance.listen({ host, port });
|
|
59
|
+
},
|
|
60
|
+
stop: async () => {
|
|
61
|
+
await instance.close();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
fastify
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapter/fastify.ts"],"sourcesContent":["import { AdapterFactory } from '@mcphero/core'\nimport { buildLogLevels, Logger, LogLevel } from '@mcphero/logger'\nimport { FastifyBaseLogger, FastifyHttpOptions, fastify as fastifyInstance } from 'fastify'\nimport { Server } from 'http'\n\ntype FastifyLogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace'\n\nconst PINO_LEVEL_MAP: Record<LogLevel, FastifyLogLevel> = {\n emergency: 'fatal',\n alert: 'fatal',\n critical: 'fatal',\n error: 'error',\n warning: 'warn',\n notice: 'debug',\n info: 'info',\n debug: 'debug'\n}\n\nexport interface FastifyAdapterOptions extends FastifyHttpOptions<Server, FastifyBaseLogger> {\n host?: string\n port?: number\n}\n\nexport const fastify: AdapterFactory<FastifyAdapterOptions> = ({ host, port, ...fastifyOptions }) => {\n const instance = fastifyInstance(fastifyOptions)\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'fastify' })\n return {\n context,\n start: async (actions) => {\n await instance.register(import('@fastify/swagger'), {\n openapi: {\n info: {\n title: options.name,\n description: options.description,\n version: options.version\n }\n }\n })\n await instance.register(import('@scalar/fastify-api-reference'), { routePrefix: '/' as `/${string}` })\n for (const action of actions) {\n const schema = action.input.toJSONSchema()\n instance.post(`/${action.name}`, {\n schema: {\n description: action.description,\n body: {\n type: 'object',\n properties: schema.properties,\n required: schema.required\n },\n response: {\n 200: { description: 'Successful response' }\n }\n }\n }, (request) => {\n const logger: Logger = {\n ...buildLogLevels((level, data) => {\n const pinoLevel = PINO_LEVEL_MAP[level] ?? 'info'\n instance.log[pinoLevel](data)\n }),\n progress: ({ progress, total, message }) => { instance.log.trace({ progress, total }, message) }\n }\n return action.run(request.body, context.fork({ logger, request }))\n })\n }\n await instance.listen({ host, port })\n },\n stop: async () => { await instance.close() }\n }\n }\n}\n"],"mappings":";AACA,SAAS,sBAAwC;AACjD,SAAgD,WAAW,uBAAuB;AAKlF,IAAM,iBAAoD;AAAA,EACxD,WAAW;AAAA,EACX,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AACT;AAOO,IAAM,UAAiD,CAAC,EAAE,MAAM,MAAM,GAAG,eAAe,MAAM;AACnG,QAAM,WAAW,gBAAgB,cAAc;AAC/C,SAAO,CAAC,SAAS,gBAAgB;AAC/B,UAAM,UAAU,YAAY,KAAK,EAAE,SAAS,UAAU,CAAC;AACvD,WAAO;AAAA,MACL;AAAA,MACA,OAAO,OAAO,YAAY;AACxB,cAAM,SAAS,SAAS,OAAO,kBAAkB,GAAG;AAAA,UAClD,SAAS;AAAA,YACP,MAAM;AAAA,cACJ,OAAO,QAAQ;AAAA,cACf,aAAa,QAAQ;AAAA,cACrB,SAAS,QAAQ;AAAA,YACnB;AAAA,UACF;AAAA,QACF,CAAC;AACD,cAAM,SAAS,SAAS,OAAO,+BAA+B,GAAG,EAAE,aAAa,IAAoB,CAAC;AACrG,mBAAW,UAAU,SAAS;AAC5B,gBAAM,SAAS,OAAO,MAAM,aAAa;AACzC,mBAAS,KAAK,IAAI,OAAO,IAAI,IAAI;AAAA,YAC/B,QAAQ;AAAA,cACN,aAAa,OAAO;AAAA,cACpB,MAAM;AAAA,gBACJ,MAAM;AAAA,gBACN,YAAY,OAAO;AAAA,gBACnB,UAAU,OAAO;AAAA,cACnB;AAAA,cACA,UAAU;AAAA,gBACR,KAAK,EAAE,aAAa,sBAAsB;AAAA,cAC5C;AAAA,YACF;AAAA,UACF,GAAG,CAAC,YAAY;AACd,kBAAM,SAAiB;AAAA,cACrB,GAAG,eAAe,CAAC,OAAO,SAAS;AACjC,sBAAM,YAAY,eAAe,KAAK,KAAK;AAC3C,yBAAS,IAAI,SAAS,EAAE,IAAI;AAAA,cAC9B,CAAC;AAAA,cACD,UAAU,CAAC,EAAE,UAAU,OAAO,QAAQ,MAAM;AAAE,yBAAS,IAAI,MAAM,EAAE,UAAU,MAAM,GAAG,OAAO;AAAA,cAAE;AAAA,YACjG;AACA,mBAAO,OAAO,IAAI,QAAQ,MAAM,QAAQ,KAAK,EAAE,QAAQ,QAAQ,CAAC,CAAC;AAAA,UACnE,CAAC;AAAA,QACH;AACA,cAAM,SAAS,OAAO,EAAE,MAAM,KAAK,CAAC;AAAA,MACtC;AAAA,MACA,MAAM,YAAY;AAAE,cAAM,SAAS,MAAM;AAAA,MAAE;AAAA,IAC7C;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcphero/fastify",
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "MCP Hero Fastify REST Adapter",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+ssh://git@github.com/atomicbi/mcphero.git",
|
|
8
|
+
"directory": "packages/fastify"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "build/index.js",
|
|
12
|
+
"types": "build/index.d.ts",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@fastify/swagger": "^9.7.0",
|
|
15
|
+
"@scalar/fastify-api-reference": "^1.49.0",
|
|
16
|
+
"fastify": "^5.8.2",
|
|
17
|
+
"zod": "^4.3.6",
|
|
18
|
+
"@mcphero/core": "1.1.6",
|
|
19
|
+
"@mcphero/logger": "1.1.6"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@eslint/js": "^10.0.1",
|
|
23
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
24
|
+
"@types/node": "^22.0.0",
|
|
25
|
+
"rimraf": "^6.1.3",
|
|
26
|
+
"tsup": "^8.5.1",
|
|
27
|
+
"tsx": "^4.21.0",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"typescript-eslint": "^8.56.1"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"clean": "rimraf build",
|
|
33
|
+
"build": "tsup",
|
|
34
|
+
"watch": "tsup --watch",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"lint": "eslint",
|
|
37
|
+
"check": "pnpm lint && pnpm typecheck"
|
|
38
|
+
}
|
|
39
|
+
}
|