All files / src constants.ts

100% Statements 14/14
42.85% Branches 6/14
100% Functions 1/1
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59    9x 18x           9x 9x 9x   9x                   9x           9x   9x   9x         9x   9x                         9x       9x  
import PaymentDetails from "./core/types/paymentDetails";
 
const localOrService = (serviceName: string) =>
    process.env.NODE_ENV === 'test_integration'
        ? '0.0.0.0'
        : process.env.WITH_BRIDGE_NETWORK === '1'
            ? serviceName
            : 'localhost';
 
export default class Constants {
    public static DbComposeServiceName = 'db' as const;
    public static AppComposeServiceName = 'app' as const;
 
    public static readonly Defaults = {
        port: 8000 as const,
        mariadbHost: localOrService(this.DbComposeServiceName),
        mariadbPort: 3306 as const,
        mariadbPassword: 'password' as const,
        mariadbUser: 'root' as const,
        mariadbDatabase: 'unixpense' as const,
        containerTimeout: 5 * 1000, // 5s
    }
 
    public static readonly scopes = [
        'https://www.googleapis.com/auth/userinfo.profile',
        'https://www.googleapis.com/auth/userinfo.email',
        'https://www.googleapis.com/auth/gmail.readonly'
    ] as const;
 
    public static readonly host = localOrService(this.AppComposeServiceName);
 
    public static readonly port = process.env.PORT ?? Constants.Defaults.port;
 
    public static readonly baseUrl = `${process.env.NODE_ENV === 'production'
        ? `https://${process.env.UNIXPENSE_HOST}${process.env.UNIXPENSE_HOST_PREFIX ?? ''}`
        : `http://${Constants.host}:${Constants.port}`
    }`;
 
    public static readonly defaultRedirectUri = `${Constants.baseUrl}/api/oauthcallback` as const;
 
    public static readonly Mock = {
        userEmail: "email" as const,
        clientId: "client_id" as const,
        clientSecret: "client_secret" as const,
        redirectUri: "redirect_uri" as const,
        authorizationCode: "code" as const,
        authorizationCodeError: "error_code" as const,
        accessToken: "access_token" as const,
        refreshToken: "refresh_token" as const,
        emptyTransactionSourceId: "empty" as const,
        errorTransactionSourceId: "error" as const
    } as const;
 
    public static readonly defaultPaymentDetails: PaymentDetails = {
        recipient: '<N/A>'
    };
 
    public static readonly defaultTransactionCount: number = 25;
}