MCPcopy Create free account
hub / github.com/PalisadoesFoundation/talawa-api / apiSetup

Function apiSetup

scripts/setup/setup.ts:747–956  ·  view source on GitHub ↗
(answers: SetupAnswers)

Source from the content-addressed store, hash-verified

745}
746
747export async function apiSetup(answers: SetupAnswers): Promise<SetupAnswers> {
748 try {
749 answers.API_BASE_URL = await promptInput(
750 "API_BASE_URL",
751 "API base URL:",
752 "http://127.0.0.1:4000",
753 validateURL,
754 );
755 answers.API_HOST = await promptInput("API_HOST", "API host:", "0.0.0.0");
756 answers.API_PORT = await promptInput(
757 "API_PORT",
758 "API port:",
759 "4000",
760 validatePort,
761 );
762 answers.API_IS_APPLY_DRIZZLE_MIGRATIONS = await promptList(
763 "API_IS_APPLY_DRIZZLE_MIGRATIONS",
764 "Apply Drizzle migrations?",
765 ["true", "false"],
766 "true",
767 );
768 answers.API_IS_GRAPHIQL = await promptList(
769 "API_IS_GRAPHIQL",
770 "Enable GraphQL?",
771 ["true", "false"],
772 answers.CI === "false" ? "true" : "false",
773 );
774 answers.API_IS_PINO_PRETTY = await promptList(
775 "API_IS_PINO_PRETTY",
776 "Enable Pino Pretty logs?",
777 ["true", "false"],
778 answers.CI === "false" ? "true" : "false",
779 );
780 answers.API_JWT_EXPIRES_IN = await promptInput(
781 "API_JWT_EXPIRES_IN",
782 "JWT expiration (ms):",
783 "2592000000",
784 );
785 const jwtSecret = generateJwtSecret();
786 answers.API_JWT_SECRET = await promptInput(
787 "API_JWT_SECRET",
788 "JWT secret:",
789 jwtSecret,
790 (input: string) => {
791 const trimmed = input.trim();
792 if (trimmed.length < 128) {
793 return "JWT secret must be at least 128 characters long.";
794 }
795 return true;
796 },
797 );
798
799 answers.API_EMAIL_VERIFICATION_TOKEN_EXPIRES_SECONDS = await promptInput(
800 "API_EMAIL_VERIFICATION_TOKEN_EXPIRES_SECONDS",
801 "Email verification token expiration (seconds):",
802 "86400",
803 (input: string) => {
804 const seconds = Number.parseInt(input, 10);

Callers 2

apiSetup.test.tsFile · 0.90
setupFunction · 0.85

Calls 4

promptInputFunction · 0.90
promptListFunction · 0.90
generateJwtSecretFunction · 0.90
handlePromptErrorFunction · 0.85

Tested by

no test coverage detected