|
| 1 | +import { defaultNumber, minLength, parseInteger, required } from "./validate"; |
| 2 | + |
1 | 3 | // @ts-ignore
|
2 | 4 | const packageJson = require("../../../package.json");
|
3 | 5 |
|
4 | 6 | // TODO: customise this with your own settings!
|
5 | 7 |
|
6 |
| -export const fromEmail = |
7 |
| - '"PostGraphile Starter" <[email protected]>'; |
8 |
| -export const awsRegion = "us-east-1"; |
9 |
| -export const projectName = packageJson.name.replace(/[-_]/g, " "); |
10 |
| -export const companyName = projectName; // For copyright ownership |
11 |
| -export const emailLegalText = |
| 8 | +export const fromEmail: string = `"PostGraphile Starter" <[email protected]>`; |
| 9 | +export const awsRegion: string = "us-east-1"; |
| 10 | +export const projectName: string = packageJson.name.replace(/[-_]/g, " "); |
| 11 | +export const companyName: string = projectName; // For copyright ownership |
| 12 | +export const emailLegalText: string = |
12 | 13 | // Envvar here so we can override on the demo website
|
13 | 14 | process.env.LEGAL_TEXT || "<Insert legal email footer text here >";
|
| 15 | + |
| 16 | +export const SECRET: string = minLength( |
| 17 | + required({ value: process.env.SECRET, name: "SECRET" }), |
| 18 | + 64 |
| 19 | +).value; |
| 20 | + |
| 21 | +export const JWT_SECRET: string = minLength( |
| 22 | + required({ |
| 23 | + value: process.env.JWT_SECRET, |
| 24 | + name: "JWT_SECRET", |
| 25 | + }), |
| 26 | + 64 |
| 27 | +).value; |
| 28 | + |
| 29 | +export const REDIS_URL: string | undefined = process.env.REDIS_URL; |
| 30 | + |
| 31 | +export const DATABASE_URL: string = required({ |
| 32 | + value: process.env.DATABASE_URL, |
| 33 | + name: "DATABASE_URL", |
| 34 | +}).value; |
| 35 | + |
| 36 | +export const AUTH_DATABASE_URL: string = required({ |
| 37 | + value: process.env.AUTH_DATABASE_URL, |
| 38 | + name: "AUTH_DATABASE_URL", |
| 39 | +}).value; |
| 40 | + |
| 41 | +export const NODE_ENV: string = required({ |
| 42 | + value: process.env.NODE_ENV, |
| 43 | + name: "NODE_ENV", |
| 44 | +}).value; |
| 45 | + |
| 46 | +export const isDev: boolean = NODE_ENV === "development"; |
| 47 | + |
| 48 | +export const isTest: boolean = NODE_ENV === "test"; |
| 49 | + |
| 50 | +export const isDevOrTest: boolean = isDev || isTest; |
| 51 | + |
| 52 | +export const ROOT_URL: string = required({ |
| 53 | + value: process.env.ROOT_URL, |
| 54 | + name: "ROOT_URL", |
| 55 | +}).value; |
| 56 | + |
| 57 | +export const TRUST_PROXY: string | undefined = process.env.TRUST_PROXY; |
| 58 | + |
| 59 | +export const ENABLE_GRAPHIQL: boolean = !!process.env.ENABLE_GRAPHIQL; |
| 60 | + |
| 61 | +export const GRAPHILE_LICENSE: string | undefined = |
| 62 | + process.env.GRAPHILE_LICENSE; |
| 63 | +// Pro plugin options (requires process.env.GRAPHILE_LICENSE) |
| 64 | +export const GRAPHQL_PAGINATION_CAP: number = defaultNumber( |
| 65 | + parseInteger({ |
| 66 | + value: process.env.GRAPHQL_PAGINATION_CAP, |
| 67 | + name: "GRAPHQL_PAGINATION_CAP", |
| 68 | + }), |
| 69 | + 50 |
| 70 | +).value; |
| 71 | +export const GRAPHQL_DEPTH_LIMIT: number = defaultNumber( |
| 72 | + parseInteger({ |
| 73 | + value: process.env.GRAPHQL_DEPTH_LIMIT, |
| 74 | + name: "GRAPHQL_DEPTH_LIMIT", |
| 75 | + }), |
| 76 | + 12 |
| 77 | +).value; |
| 78 | +export const GRAPHQL_COST_LIMIT: number = defaultNumber( |
| 79 | + parseInteger({ |
| 80 | + value: process.env.GRAPHQL_COST_LIMIT, |
| 81 | + name: "GRAPHQL_COST_LIMIT", |
| 82 | + }), |
| 83 | + 30000 |
| 84 | +).value; |
| 85 | +export const HIDE_QUERY_COST: boolean = |
| 86 | + defaultNumber( |
| 87 | + parseInteger({ |
| 88 | + value: process.env.HIDE_QUERY_COST, |
| 89 | + name: "HIDE_QUERY_COST", |
| 90 | + }), |
| 91 | + 0 |
| 92 | + ).value < 1; |
| 93 | + |
| 94 | +export const PORT: number = defaultNumber( |
| 95 | + parseInteger({ value: process.env.PORT, name: "PORT" }), |
| 96 | + 3000 |
| 97 | +).value; |
| 98 | + |
| 99 | +export const ENABLE_CYPRESS_COMMANDS: boolean = |
| 100 | + process.env.ENABLE_CYPRESS_COMMANDS === "1"; |
| 101 | + |
| 102 | +export const GITHUB_KEY: string | undefined = process.env.GITHUB_KEY; |
| 103 | +export const GITHUB_SECRET: string | undefined = process.env.GITHUB_SECRET; |
| 104 | + |
| 105 | +export const DATABASE_VISITOR: string | undefined = |
| 106 | + process.env.DATABASE_VISITOR; |
| 107 | + |
| 108 | +const MILLISECOND = 1; |
| 109 | +const SECOND = 1000 * MILLISECOND; |
| 110 | +const MINUTE = 60 * SECOND; |
| 111 | +const HOUR = 60 * MINUTE; |
| 112 | +const DAY = 24 * HOUR; |
| 113 | +export const MAXIMUM_SESSION_DURATION_IN_MILLISECONDS: number = defaultNumber( |
| 114 | + parseInteger({ |
| 115 | + value: process.env.MAXIMUM_SESSION_DURATION_IN_MILLISECONDS, |
| 116 | + name: "MAXIMUM_SESSION_DURATION_IN_MILLISECONDS", |
| 117 | + }), |
| 118 | + 3 * DAY |
| 119 | +).value; |
| 120 | + |
| 121 | +export const T_AND_C_URL: string | undefined = process.env.T_AND_C_URL; |
0 commit comments