launchcodedev / app-config

Easy Configuration Loader with Strict Validation
https://app-config.dev
Mozilla Public License 2.0
69 stars 11 forks source link

Can i know which team member is running the application in runtime? #220

Open nicolasmelo1 opened 1 year ago

nicolasmelo1 commented 1 year ago

I want to make development easier for me and my coworkers so i wanted to have baked in documentation for developers in the company.

Let's say i'm creating a simple authentication flow based on OTP in Nest.js

@ApiTags('auth')
@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Get('/otp')
  @ApiOperation({
    summary:
      'This is used for logging the user in when testing the app. It will send to you an OTP code to your phone number. After this you should log in with "/login" endpoint.',
  })
  @ApiQuery({
    name: 'phoneNumber',
    description: 'The phone number to send the OTP code to, so you can log in.',
    required: true,
    type: String,
    example: '+5511970852396', // this is my phone number, i wanted this to be dynamic then other co-workers that will to run this code don't need to manually change this.
  })
  @ApiResponse({
    status: 200,
    description:
      'If you receive a 200 HTTP status code, the OTP code was sent to the phone number.',
  })
  async sendOtpCode(@Query('phoneNumber') phoneNumber?: string) {
    if (phoneNumber) await this.authService.otp(phoneNumber);
    return;
  }
}

I could create a json file alongside with the team members and we would be able to configure our phone numbers to better document everything.

Another use case might be for mobile development. When i'm developing for mobile and want to run the code on my device i can't use localhost, instead i need to transform the localhost to my actual host of my wifi router.

const client = new QueryClient();
storage.setSecureStorage(secureStorage);
storage.setUnsecureStorage(unsecureStorage);
api.setApiPath(__DEV__ ? config.api.url.replace('localhost', '192.168.0.211') : config.api.url); // i wanted to manually configure the localhost replacement for the user running the application when in development
api.setPrefix('api');

void initializePolyfills(['format-js']);

export default function App() {
    // rest of code
}

With this i can improve the DX on our projects.

nicolasmelo1 commented 1 year ago

Just a teamMember based configuration within app-config would be more than enough i think, then we doesn't leak our personal data to others.

joelgallant commented 1 year ago

Hey! How can app-config help solve this problem? Isn't it possible already to put teamMembers in configuration? Or maybe I've missed how this would work.

An example of what app-config files might look like would help