Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export the filename as a constant in the generated files for convenient #1160

Open
kasir-barati opened this issue Feb 2, 2025 · 0 comments

Comments

@kasir-barati
Copy link

Assume I have a protobuf file called abc.proto as follows:

syntax = "proto3";
package pop.www.bbb;
// ...

I wonder if there is a real reason why this lib is not creating another constant variable to gives devs the file name of the protobuf file, something like this:

export const protobufPackageAbc = "abc.proto"
export const ABC_PROTOBUF_FILENAME = "abc.proto"

Exactly like the protobufPackage or the one with a more descriptive name which I usually use with the same value as protobufPackage:

// ...
export const protobufPackage = "pop.www.bbb";
export const POP_WWW_BBB_PACKAGE_NAME = "pop.www.bbb";
// ...

This can help in places like this: https://github.com/kasir-barati/nestjs-materials/blob/182f05d3414f0ad6b1222fdabc4472d4b0a13561/microservices/grpc/apps/nestjs-client/src/main.ts#L28

Instead of that code then I can simply import the filename, though I can see that one might think that just type the freaking filename and get over with it. But the way I look at it I can see myself using the same string in multiple places and if I import it instead of typing it I would say it less prone to errors and bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant