@funduck/connectrpc-fastify 1.0.0 → 1.0.1

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.
@@ -1,97 +0,0 @@
1
- // @generated by protoc-gen-es v2.10.2 with parameter "target=ts"
2
- // @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3)
3
- /* eslint-disable */
4
-
5
- import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
6
- import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
7
- import { file_buf_validate_validate } from "../../../buf/validate/validate_pb";
8
- import type { Message } from "@bufbuild/protobuf";
9
-
10
- /**
11
- * Describes the file connectrpc/eliza/v1/eliza.proto.
12
- */
13
- export const file_connectrpc_eliza_v1_eliza: GenFile = /*@__PURE__*/
14
- fileDesc("Ch9jb25uZWN0cnBjL2VsaXphL3YxL2VsaXphLnByb3RvEhNjb25uZWN0cnBjLmVsaXphLnYxIioKClNheVJlcXVlc3QSHAoIc2VudGVuY2UYASABKAlCCrpIB3IFEAEY+gEiHwoLU2F5UmVzcG9uc2USEAoIc2VudGVuY2UYASABKAkiQwoMU2F5UmVzcG9uc2VzEjMKCXJlc3BvbnNlcxgBIAMoCzIgLmNvbm5lY3RycGMuZWxpemEudjEuU2F5UmVzcG9uc2UyggIKDEVsaXphU2VydmljZRJKCgNTYXkSHy5jb25uZWN0cnBjLmVsaXphLnYxLlNheVJlcXVlc3QaIC5jb25uZWN0cnBjLmVsaXphLnYxLlNheVJlc3BvbnNlIgASUQoHU2F5TWFueRIfLmNvbm5lY3RycGMuZWxpemEudjEuU2F5UmVxdWVzdBohLmNvbm5lY3RycGMuZWxpemEudjEuU2F5UmVzcG9uc2VzIgAoARJTCgpMaXN0ZW5NYW55Eh8uY29ubmVjdHJwYy5lbGl6YS52MS5TYXlSZXF1ZXN0GiAuY29ubmVjdHJwYy5lbGl6YS52MS5TYXlSZXNwb25zZSIAMAFiBnByb3RvMw", [file_buf_validate_validate]);
15
-
16
- /**
17
- * @generated from message connectrpc.eliza.v1.SayRequest
18
- */
19
- export type SayRequest = Message<"connectrpc.eliza.v1.SayRequest"> & {
20
- /**
21
- * @generated from field: string sentence = 1;
22
- */
23
- sentence: string;
24
- };
25
-
26
- /**
27
- * Describes the message connectrpc.eliza.v1.SayRequest.
28
- * Use `create(SayRequestSchema)` to create a new message.
29
- */
30
- export const SayRequestSchema: GenMessage<SayRequest> = /*@__PURE__*/
31
- messageDesc(file_connectrpc_eliza_v1_eliza, 0);
32
-
33
- /**
34
- * @generated from message connectrpc.eliza.v1.SayResponse
35
- */
36
- export type SayResponse = Message<"connectrpc.eliza.v1.SayResponse"> & {
37
- /**
38
- * @generated from field: string sentence = 1;
39
- */
40
- sentence: string;
41
- };
42
-
43
- /**
44
- * Describes the message connectrpc.eliza.v1.SayResponse.
45
- * Use `create(SayResponseSchema)` to create a new message.
46
- */
47
- export const SayResponseSchema: GenMessage<SayResponse> = /*@__PURE__*/
48
- messageDesc(file_connectrpc_eliza_v1_eliza, 1);
49
-
50
- /**
51
- * @generated from message connectrpc.eliza.v1.SayResponses
52
- */
53
- export type SayResponses = Message<"connectrpc.eliza.v1.SayResponses"> & {
54
- /**
55
- * @generated from field: repeated connectrpc.eliza.v1.SayResponse responses = 1;
56
- */
57
- responses: SayResponse[];
58
- };
59
-
60
- /**
61
- * Describes the message connectrpc.eliza.v1.SayResponses.
62
- * Use `create(SayResponsesSchema)` to create a new message.
63
- */
64
- export const SayResponsesSchema: GenMessage<SayResponses> = /*@__PURE__*/
65
- messageDesc(file_connectrpc_eliza_v1_eliza, 2);
66
-
67
- /**
68
- * @generated from service connectrpc.eliza.v1.ElizaService
69
- */
70
- export const ElizaService: GenService<{
71
- /**
72
- * @generated from rpc connectrpc.eliza.v1.ElizaService.Say
73
- */
74
- say: {
75
- methodKind: "unary";
76
- input: typeof SayRequestSchema;
77
- output: typeof SayResponseSchema;
78
- },
79
- /**
80
- * @generated from rpc connectrpc.eliza.v1.ElizaService.SayMany
81
- */
82
- sayMany: {
83
- methodKind: "client_streaming";
84
- input: typeof SayRequestSchema;
85
- output: typeof SayResponsesSchema;
86
- },
87
- /**
88
- * @generated from rpc connectrpc.eliza.v1.ElizaService.ListenMany
89
- */
90
- listenMany: {
91
- methodKind: "server_streaming";
92
- input: typeof SayRequestSchema;
93
- output: typeof SayResponseSchema;
94
- },
95
- }> = /*@__PURE__*/
96
- serviceDesc(file_connectrpc_eliza_v1_eliza, 0);
97
-
package/test/guards.ts DELETED
@@ -1,13 +0,0 @@
1
- import { ConnectRPC, ExecutionContext, Guard } from '../src/index';
2
-
3
- export class TestGuard1 implements Guard {
4
- static callback = (context: ExecutionContext) => true;
5
-
6
- constructor() {
7
- ConnectRPC.registerGuard(this);
8
- }
9
-
10
- canActivate(context: ExecutionContext): boolean {
11
- return TestGuard1.callback(context);
12
- }
13
- }
@@ -1,50 +0,0 @@
1
- import { FastifyReply, FastifyRequest } from 'fastify';
2
- import { ConnectRPC, Middleware } from '../src/index';
3
-
4
- export class TestMiddleware1 implements Middleware {
5
- static callback = (req: FastifyRequest['raw'], res: FastifyReply['raw']) =>
6
- null;
7
-
8
- constructor() {
9
- ConnectRPC.registerMiddleware(this, {
10
- allowMultipleInstances: false, // If true, we allow multiple instances of this middleware, but usually we want only one
11
- });
12
- }
13
-
14
- use(req: FastifyRequest['raw'], res: FastifyReply['raw'], next: () => void) {
15
- TestMiddleware1.callback(req, res);
16
- next();
17
- }
18
- }
19
-
20
- export class TestMiddleware2 implements Middleware {
21
- static callback = (req: FastifyRequest['raw'], res: FastifyReply['raw']) =>
22
- null;
23
-
24
- constructor() {
25
- ConnectRPC.registerMiddleware(this, {
26
- allowMultipleInstances: false, // If true, we allow multiple instances of this middleware, but usually we want only one
27
- });
28
- }
29
-
30
- use(req: FastifyRequest['raw'], res: FastifyReply['raw'], next: () => void) {
31
- TestMiddleware2.callback(req, res);
32
- next();
33
- }
34
- }
35
-
36
- export class TestMiddleware3 implements Middleware {
37
- static callback = (req: FastifyRequest['raw'], res: FastifyReply['raw']) =>
38
- null;
39
-
40
- constructor() {
41
- ConnectRPC.registerMiddleware(this, {
42
- allowMultipleInstances: false, // If true, we allow multiple instances of this middleware, but usually we want only one
43
- });
44
- }
45
-
46
- use(req: FastifyRequest['raw'], res: FastifyReply['raw'], next: () => void) {
47
- TestMiddleware3.callback(req, res);
48
- next();
49
- }
50
- }
@@ -1,26 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package connectrpc.eliza.v1;
4
-
5
- import "buf/validate/validate.proto";
6
-
7
- message SayRequest {
8
- string sentence = 1 [
9
- (buf.validate.field).string.min_len = 1,
10
- (buf.validate.field).string.max_len = 250
11
- ];
12
- }
13
-
14
- message SayResponse {
15
- string sentence = 1;
16
- }
17
-
18
- message SayResponses {
19
- repeated SayResponse responses = 1;
20
- }
21
-
22
- service ElizaService {
23
- rpc Say(SayRequest) returns (SayResponse) {}
24
- rpc SayMany(stream SayRequest) returns (SayResponses) {}
25
- rpc ListenMany(SayRequest) returns (stream SayResponse) {}
26
- }
package/test/server.ts DELETED
@@ -1,47 +0,0 @@
1
- import Fastify from 'fastify';
2
- import { ConnectRPC, middlewareConfig } from '../src/index';
3
- import { ElizaController } from './controller';
4
- import { ElizaService } from './gen/connectrpc/eliza/v1/eliza_pb';
5
- import { TestGuard1 } from './guards';
6
- import {
7
- TestMiddleware1,
8
- TestMiddleware2,
9
- TestMiddleware3,
10
- } from './middlewares';
11
-
12
- export async function bootstrap() {
13
- const fastify = Fastify({
14
- logger: true,
15
- });
16
-
17
- // Declare a route
18
- fastify.get('/', async function handler(request, reply) {
19
- return { hello: 'world' };
20
- });
21
-
22
- new ElizaController();
23
-
24
- new TestMiddleware1();
25
- new TestMiddleware2();
26
- new TestMiddleware3();
27
-
28
- new TestGuard1();
29
-
30
- await ConnectRPC.registerFastifyPlugin(fastify);
31
-
32
- ConnectRPC.initMiddlewares(fastify, [
33
- middlewareConfig(TestMiddleware1), // Global middleware for all services and methods
34
- middlewareConfig(TestMiddleware2, ElizaService), // Middleware for all ElizaService methods
35
- middlewareConfig(TestMiddleware3, ElizaService, ['say']), // Middleware for ElizaService's say method only
36
- ]);
37
-
38
- ConnectRPC.initGuards(fastify);
39
-
40
- // Run the server!
41
- try {
42
- await fastify.listen({ port: 3000 });
43
- } catch (err) {
44
- fastify.log.error(err);
45
- process.exit(1);
46
- }
47
- }
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4
- }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "nodenext",
4
- "moduleResolution": "nodenext",
5
- "resolvePackageJsonExports": true,
6
- "esModuleInterop": true,
7
- "isolatedModules": true,
8
- "declaration": true,
9
- "removeComments": true,
10
- "emitDecoratorMetadata": true,
11
- "experimentalDecorators": true,
12
- "allowSyntheticDefaultImports": true,
13
- "target": "ES2023",
14
- "sourceMap": true,
15
- "rootDir": "./",
16
- "outDir": "./dist",
17
- "paths": { "src/*": ["./src/*"] },
18
- "incremental": true,
19
- "skipLibCheck": true,
20
- "strictNullChecks": true,
21
- "forceConsistentCasingInFileNames": true,
22
- "noImplicitAny": false,
23
- "strictBindCallApply": false,
24
- "noFallthroughCasesInSwitch": false
25
- }
26
- }