Skip to content

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

@nicolasmelo1

Description

@nicolasmelo1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions