This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule AppWeb.GraphQL.Context do | |
| @moduledoc """ | |
| This module is responsible for setting up the context for GraphQL requests. | |
| in a production environment, the session token is used internally. In development, this is often too long to be uses as a bearer token in GraphiQL playground. | |
| In a development environment, we encode our session token in base64 and use it as a bearer token. | |
| eg. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type DiscordLogType = 'error' | 'info' | |
| interface IDiscordLog { | |
| type: DiscordLogType | |
| message: string | |
| } | |
| const embedColours: Record<DiscordLogType, number> = { | |
| error: 0xff0000, | |
| info: 0x00ff00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "compilerOptions": { | |
| //... | |
| "paths": { | |
| "@/*": ["./src/*"] | |
| }, | |
| //... | |
| }, | |
| "include": ["src"], | |
| //... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //... | |
| export const httpServer = http.createServer(app); | |
| let schema = makeExecutableSchema({ | |
| typeDefs, | |
| resolvers, | |
| }); | |
| schema = authDirectiveTransformer(schema, "auth"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const numberToCurrency = (value: number | string): string => { | |
| const numericValue = | |
| typeof value === "string" ? Number.parseFloat(value) : value; | |
| return numericValue.toLocaleString(undefined, { | |
| style: "currency", | |
| currency: "EUR", | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const downloadString = (string, filename) => { | |
| try { | |
| const element = document.createElement("a"); | |
| const file = new Blob([string], { | |
| type: "text/plain", | |
| }); | |
| element.href = URL.createObjectURL(file); | |
| element.download = filename; | |
| document.body.appendChild(element); | |
| element.click(); |