### Install and Run Locally Source: https://github.com/blinkbitcoin/blink/blob/main/apps/pay/README.md Install project dependencies and start the local development server. The application will be accessible at http://localhost:3000. ```sh yarn install yarn dev ``` -------------------------------- ### Install and Run Admin Panel Locally Source: https://github.com/blinkbitcoin/blink/blob/main/apps/admin-panel/README.md Use these commands to install dependencies and start the Admin Panel in development mode. Open http://localhost:3004 to view the application. ```bash pnpm install pnpm dev ``` -------------------------------- ### Start Runtime Dependencies Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Starts the necessary runtime dependencies for the project, such as the lightning network and database. This command should be run after installing dependencies. ```bash $ make start-deps ``` -------------------------------- ### Start Development Server Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Starts the GraphQL server and its associated dependencies. Ensure runtime dependencies are running before executing this command. ```bash $ make start ``` -------------------------------- ### Example of Viewing Targets Source: https://github.com/blinkbitcoin/blink/blob/main/docs/BUCK2.md A concrete example of using the `buck2 targets` command to view targets in the `//core/api` directory. ```shell buck2 targets //core/api ``` -------------------------------- ### Start Galoy Stack Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Starts the Galoy stack, likely a backend service or application. ```shell galoy % make start ``` -------------------------------- ### Start Docker Compose and Open GraphQL Playground Source: https://github.com/blinkbitcoin/blink/blob/main/quickstart/README.md Starts the Galoy stack using Docker Compose and opens the GraphQL playground endpoint in your browser. ```bash docker compose up -d open http://localhost:4455/graphql ``` -------------------------------- ### Install Dependencies Source: https://github.com/blinkbitcoin/blink/blob/main/apps/consent/README.md Installs project dependencies using Yarn. Ensure you have Yarn installed before running this command. ```bash yarn install ``` -------------------------------- ### Running a Buck2 Target Source: https://github.com/blinkbitcoin/blink/blob/main/docs/BUCK2.md Example of how to run a specific Buck2 target within an application directory. ```shell buck2 run apps/consent:test-integration ``` -------------------------------- ### Download vendir Configuration and Synchronize Vendor Folder Source: https://github.com/blinkbitcoin/blink/blob/main/quickstart/README.md Downloads the quickstart vendir configuration and synchronizes the vendor folder to prepare for embedding Galoy. ```bash curl https://raw.githubusercontent.com/GaloyMoney/galoy/main/quickstart/quickstart.vendir.yml > vendir.yml vendir sync ``` -------------------------------- ### Start the Development Stack with Buck2 Source: https://github.com/blinkbitcoin/blink/blob/main/README.md Use this command to build and run the entire local development stack using Buck2. This command initiates all necessary services like PostgreSQL and MongoDB. ```bash buck2 run dev:up ``` -------------------------------- ### Install Ory Hydra Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Installs the Ory Hydra command-line tool using Homebrew. ```shell brew install ory-hydra ``` -------------------------------- ### Run Development Server Source: https://github.com/blinkbitcoin/blink/blob/main/apps/dashboard/README.md Commands to start the Next.js development server using different package managers. Open http://localhost:3000 to view the application. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Install vendir and ytt Source: https://github.com/blinkbitcoin/blink/blob/main/quickstart/README.md Installs the vendir and ytt tools using Homebrew, which are required for embedding Galoy as a dependency. ```bash brew tap carvel-dev/carvel brew install vendir ytt ``` -------------------------------- ### Build for Production Source: https://github.com/blinkbitcoin/blink/blob/main/apps/pay/README.md Install dependencies and build the application for production. This optimizes the React bundle for performance and creates minified files in the `build` folder. ```sh yarn install yarn build ``` -------------------------------- ### Custom Configuration Example Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md An example of a custom.yaml file to override default Galoy configurations. This file should be placed at /var/yaml/custom.yaml and can be used to adjust settings like withdrawal fees. ```yaml fees: withdraw: method: flat defaultMin: 2000 ratioAsBasisPoints: 50 threshold: 1000000 daysLookback: 30 ``` -------------------------------- ### Run Next.js App in Development Mode Source: https://github.com/blinkbitcoin/blink/blob/main/apps/consent/README.md Starts the Next.js development server. This command is available via npm, Yarn, or pnpm. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Clones the Galoy repository and installs project dependencies using Yarn. It also initializes direnv for environment variable management. ```bash $ git clone git@github.com:GaloyMoney/galoy.git $ cd galoy $ direnv allow direnv reload direnv: direnv: loading ~/projects/GaloyMoney/galoy/.envrc (...) $ yarn install ``` -------------------------------- ### Start Hydra Login Consent Node Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Launches the Hydra login and consent node for interactive authentication with the Kratos API. ```shell apps/consent % HYDRA_ADMIN_URL=http://localhost:4445 yarn start ``` -------------------------------- ### Run Specific Test Case Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Example of running a specific test case using Jest's it.only for debugging purposes. ```javascript it.only('test case name', () => { // ... }); ``` -------------------------------- ### Create Docker Compose Alias Source: https://github.com/blinkbitcoin/blink/blob/main/quickstart/README.md Creates a shell alias 'dp' for convenient management of the Galoy Docker Compose stack, including starting and checking status. ```bash alias dp="docker compose -p $(basename "$PWD") -f ./vendor/blink-quickstart/docker-compose.yml" dp up -d dp ps ``` -------------------------------- ### Introspect Access Token Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Introspects an access token to get its metadata and status. This is useful for debugging. ```shell hydra introspect token \ --format json-pretty \ --endpoint http://localhost:4445/ \ $ory_at_TOKEN ``` -------------------------------- ### Run Integration Test with Specific Test Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Example of running a specific integration test using Jest's describe.only for debugging purposes. ```javascript describe.only('test suite name', () => { // ... }); ``` -------------------------------- ### Skip Specific Test Case Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Example of temporarily skipping a test case using Jest's it.skip when a test is broken. ```javascript it.skip('test case name', () => { // ... }); ``` -------------------------------- ### Get Token for Client Credentials Client Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Obtains a token for a client credentials grant type client. Note that the response may not include the scope in the JWT. ```shell hydra perform client-credentials \ --endpoint http://localhost:4444/ \ --client-id $client_id \ --client-secret $client_secret \ --scope editor \ --format json ``` -------------------------------- ### Building a Buck2 Target from a Different Directory Source: https://github.com/blinkbitcoin/blink/blob/main/docs/BUCK2.md Demonstrates building a target located in a different directory using the root-relative path. ```shell # Let's change our current working directory to somewhere in the repository. cd apps/dashboard # Now, let's build using a BUCK file somewhere else in the repository. buck2 build //apps/consent ``` -------------------------------- ### Buck2 Command Structure Source: https://github.com/blinkbitcoin/blink/blob/main/docs/BUCK2.md Illustrates the general syntax for Buck2 commands, including environment variables, command, directory, target, and arguments. ```shell buck2 : -- ``` -------------------------------- ### Run Test Migration Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Execute the test migration command to set up a clean database for testing migrations. ```bash make test-migrate ``` -------------------------------- ### Node.js, Yarn, Direnv, jq, Docker Versions Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Displays the versions of essential development tools. Ensure these versions are compatible with the project requirements. ```bash $ node --version v18.12.0 $ yarn --version 1.22.17 $ direnv --version 2.28.0 $ jq --version jq-1.6 $ docker --version Docker version 20.10.8, build f0df350 $ docker compose version Docker Compose version 2.0.0 ``` -------------------------------- ### Run Database Migrations Up Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Apply all pending database migrations using the migrate-mongo CLI, referencing the configuration file. ```bash # Migrate npx migrate-mongo up \ -f src/migrations/migrate-mongo-config.js ``` -------------------------------- ### Buck2 Unit and Integration Test Patterns Source: https://github.com/blinkbitcoin/blink/blob/main/docs/BUCK2.md Provides the command patterns for running unit and integration tests using Buck2. Environment variables and arguments can be passed. ```shell # Pattern for unit tests buck2 run :test-unit -- # Pattern for integration tests buck2 run :test-integration -- ``` -------------------------------- ### Run Full Test Suite Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Executes the entire test suite for the project. This requires runtime dependencies to be running. ```bash $ make test ``` -------------------------------- ### Build Admin Panel for Production Source: https://github.com/blinkbitcoin/blink/blob/main/apps/admin-panel/README.md This command builds the Admin Panel for production, optimizing the build for best performance. The output is placed in the 'build' folder. ```bash pnpm build ``` -------------------------------- ### Viewing All Targets in a Directory Source: https://github.com/blinkbitcoin/blink/blob/main/docs/BUCK2.md Command to list all available Buck2 targets within a specified directory. Remember to include the trailing colon. ```shell buck2 targets : ``` -------------------------------- ### Build and Run Docker Image Source: https://github.com/blinkbitcoin/blink/blob/main/apps/pay/README.md Build the Docker image for Galoy Pay and then run it. This command spins up a Galoy Pay instance in a Docker container, accessible at http://localhost:3000. ```sh yarn build:docker yarn dev:docker ``` -------------------------------- ### Run Unit Tests Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Executes only the unit tests for the project. Runtime dependencies are not required for this command. ```bash $ yarn test:unit # or $ make unit ``` -------------------------------- ### Run Integration Tests Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Executes the integration tests for the project. Ensure that runtime dependencies are running before executing this command. ```bash $ yarn test:integration # or $ make integration ``` -------------------------------- ### Launch Galoy Docker Compose Stack Source: https://github.com/blinkbitcoin/blink/blob/main/quickstart/README.md Launches the Galoy stack using Docker Compose with a custom project name and Docker Compose file path. ```bash docker compose -p $(basename "$PWD") -f ./vendor/blink-quickstart/docker-compose.yml up -d ``` -------------------------------- ### Create a New Migration File Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Generate a new migration file using the migrate-mongo CLI tool, specifying the configuration file. ```bash npx migrate-mongo create \ -f src/migrations/migrate-mongo-config.js ``` -------------------------------- ### Format Code with Prettier Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Use the Prettier command-line tool to format all files in the current directory. ```bash $ yarn prettier -w . ``` -------------------------------- ### Link-Time Optimization (LTO) Process Source: https://github.com/blinkbitcoin/blink/blob/main/prelude/cxx/dist_lto/README.md Shows the LTO process where translation units are compiled to LLVM bitcode (a.bc, b.bc, c.bc), merged into a single module, optimized, and then code-generated into a final binary. ```mermaid flowchart LR; header.h; header.h --> a.cpp; header.h -->|#include| b.cpp; header.h --> c.cpp; a.cpp --> a.bc; b.cpp -->|clang++ -O2 -flto -x ir| b.bc; c.cpp --> c.bc; a.bc --> a_b_c.bc; b.bc -->|linker driver| a_b_c.bc; c.bc --> a_b_c.bc; a_b_c.bc -->|opt| a_b_c_optimized.bc a_b_c_optimized.bc -->|codegen| main.o main.o --> |ld| main ``` -------------------------------- ### Local Development Environment Variables Source: https://github.com/blinkbitcoin/blink/blob/main/apps/pay/README.md Configure these environment variables in `.env.local` for local staging development. Ensure these are set correctly to connect to the staging Galoy API. ```env NEXT_PUBLIC_GRAPHQL_URL='https://api.staging.galoy.io/graphql' NEXT_PUBLIC_GRAPHQL_WEBSOCKET_URL='wss://ws.staging.galoy.io/graphql' GRAPHQL_URL_INTERNAL="http://api.galoy-staging-galoy.svc.cluster.local" ``` -------------------------------- ### GraphQL Query for User Me Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Fetches user information, including their ID and default account ID, using a GraphQL query. ```shell curl --location 'http://localhost:4455/graphql' \ --header 'Content-Type: application/json' \ --header "Oauth2-Token: $ory_at_TOKEN" \ --data '{"query":"query me {\n me {\n id\n defaultAccount {\n id\n }\n }\n}","variables":{}}' ``` -------------------------------- ### Buck2 Target Name Shorthand Source: https://github.com/blinkbitcoin/blink/blob/main/docs/BUCK2.md Shows how Buck2 allows omitting the target name if it matches the directory name. ```shell # This... buck2 build apps/consent # is the same as this... buck2 build apps/consent:consent # and this... buck2 build //apps/consent # is the same as this. buck2 build //apps/consent:consent ``` -------------------------------- ### Create PKCE OAuth2 Client Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Creates an OAuth2 client for PKCE flow, allowing authorization code and ID token responses. The token endpoint authentication method is set to 'none'. ```shell code_client=$(hydra create client \ --endpoint http://localhost:4445 \ --grant-type authorization_code \ --response-type code,id_token \ --format json \ --scope read --scope write \ --redirect-uri http://localhost:5555/callback \ --token-endpoint-auth-method none ) CLIENT_ID=$(echo $code_client | jq -r '.client_id') ``` -------------------------------- ### Generate Supergraph SDL Source: https://github.com/blinkbitcoin/blink/blob/main/dev/config/apollo-federation/README.md Run this command to generate the Schema Definition Language (SDL) for your supergraph. This is the primary command for building the supergraph. ```bash pnpm run write-sdl ``` -------------------------------- ### View File Descriptor Limits Source: https://github.com/blinkbitcoin/blink/blob/main/docs/DEVELOPMENT_ENVIRONMENT.md Use this command to view the current file descriptor limits on your system. This is useful for diagnosing issues related to `buck2` or concurrent build processes. ```bash ulimit -a ``` -------------------------------- ### ThinLTO Compilation Flow Source: https://github.com/blinkbitcoin/blink/blob/main/prelude/cxx/dist_lto/README.md Outlines the ThinLTO process, involving parallel compilation to bitcode, an 'index' step to determine optimization groups, and parallel 'opt' steps for each object file. ```mermaid flowchart LR; header.h; header.h --> a.cpp; header.h -->|#include| b.cpp; header.h --> c.cpp; a.cpp --> a.bc; b.cpp -->|clang++ -O2 -flto -x ir| b.bc; c.cpp --> c.bc; a.bc --> index; b.bc --> index; c.bc --> index; index --> a.thinlto.bc; index --> b.thinlto.bc; index --> c.thinlto.bc; a.thinlto.bc --> a.o; b.thinlto.bc --> b.o; b.bc --> a.o; b.bc --> c.o; c.thinlto.bc --> c.o; a.o --> main; b.o -->|ld| main; c.o --> main; ``` -------------------------------- ### Create Client Credentials OAuth2 Client Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Creates an OAuth2 client specifically for the client credentials grant type, with 'editor' scope. ```shell client=$(hydra create client \ --endpoint http://localhost:4445/ \ --format json \ --grant-type client_credentials \ --scope editor \ ) export client_id=$(echo $client | jq -r '.client_id') export client_secret=$(echo $client | jq -r '.client_secret') ``` -------------------------------- ### Run Specific Integration Test File Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Executes a specific integration test file by specifying a test name. The `TEST` environment variable is used to target the file. ```bash $ TEST=01-connection yarn test:integration ``` -------------------------------- ### Run Buck2 Health Check Source: https://github.com/blinkbitcoin/blink/blob/main/docs/DEVELOPMENT_ENVIRONMENT.md Execute the `buck2` health check to determine an acceptable file descriptor limit for your system. This command helps in finding a suitable value for `ulimit -n`. ```bash buck2 run dev:healthcheck ``` -------------------------------- ### Run Specific Unit Test File Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Executes a specific unit test file by specifying a test name. The `TEST` environment variable is used to target the file. ```bash $ TEST=utils yarn test:unit # or $ TEST=utils make unit ``` -------------------------------- ### Run All Code Checks Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Execute all code checks required to pass GitHub actions, including linting and formatting. ```bash $ make check-code (...) $ echo $? ``` -------------------------------- ### Basic Authentication for GraphQL Decisions Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Attempts to authenticate with the GraphQL decisions endpoint using basic authentication with client ID and secret. ```shell curl -s -I -X POST http://localhost:4456/decisions/graphql --user $client_id:$client_secret ``` -------------------------------- ### Compose Supergraph with Rover CLI Source: https://github.com/blinkbitcoin/blink/blob/main/dev/config/apollo-federation/README.md This command executes the actual supergraph composition using the Rover CLI. It requires a configuration file and accepts the ELV2 license. The output is redirected to a file. ```bash rover supergraph compose \ --config dev/apollo-federation/supergraph-config.yaml \ --elv2-license accept \ > dev/apollo-federation/supergraph.graphql ``` -------------------------------- ### Parallel Compilation of Translation Units Source: https://github.com/blinkbitcoin/blink/blob/main/prelude/cxx/dist_lto/README.md Illustrates the standard compilation process where individual translation units (a.cpp, b.cpp, c.cpp) are compiled in parallel to object files (a.o, b.o, c.o), which are then linked. ```mermaid flowchart LR; header.h; header.h --> a.cpp; header.h -->|#include| b.cpp; header.h --> c.cpp; a.cpp --> a.o; b.cpp -->|clang++ -O2| b.o; c.cpp --> c.o; a.o --> main; b.o -->|ld| main; c.o --> main; ``` -------------------------------- ### Stop and Clean Development Stack with Buck2 Source: https://github.com/blinkbitcoin/blink/blob/main/README.md This command stops all running services and containers managed by Buck2, and removes them along with their data. Use this to tear down the local environment. ```bash buck2 run dev:down ``` -------------------------------- ### Google Maps API Key Configuration Source: https://github.com/blinkbitcoin/blink/blob/main/apps/map/README.md Set the NEXT_PUBLIC_MAP_API_KEY environment variable to enable Google Maps functionality. This is required for local development. ```env NEXT_PUBLIC_MAP_API_KEY ``` -------------------------------- ### Required Environment Variables Source: https://github.com/blinkbitcoin/blink/blob/main/apps/consent/README.md Lists the essential environment variables required for the application's core authentication and Hydra integration. ```plaintext CORE_AUTH_URL HYDRA_ADMIN_URL ``` -------------------------------- ### Direnv Hook for Zsh Source: https://github.com/blinkbitcoin/blink/blob/main/docs/DEVELOPMENT_ENVIRONMENT.md This snippet shows how to integrate `direnv` with the Zsh shell by adding the necessary evaluation command to your `.zshrc` file. This enables automatic environment loading for projects using `direnv`. ```bash if [ $(command -v direnv) ]; then eval "$(direnv hook zsh)" fi ``` -------------------------------- ### Compose Supergraph with Rover CLI Source: https://github.com/blinkbitcoin/blink/blob/main/quickstart/dev/config/apollo-federation/README.md This command uses the Rover CLI to compose the supergraph, referencing a configuration file and accepting the ELv2 license. ```bash $ rover supergraph compose \ --config dev/apollo-federation/supergraph-config.yaml \ --elv2-license accept \ > dev/apollo-federation/supergraph.graphql ``` -------------------------------- ### Implement Function with Argument and Return Types Source: https://github.com/blinkbitcoin/blink/blob/main/CONTRIBUTING.md Assign argument and return types directly at the point of function implementation for clarity and type safety. ```typescript const myFunction = async (myArg: MyArg): Promise => { return doThing(myArg) } const myOtherFunction = async ({ myFirstArg, mySecondArg, }: { myFirstArg: MyFirstArg mySecondArg: MySecondArg }): Promise => { return doThing(myFirstArg, mySecondArg) } ``` -------------------------------- ### Run Integration Test with Custom Timeout Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Use this command to run integration tests with a specified timeout value, useful for preventing test suite timeouts. ```bash # 120 seconds $ JEST_TIMEOUT=120000 yarn test:integration ``` -------------------------------- ### List OAuth2 Consent Sessions Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Lists consent sessions for a given subject. An optional login session ID can be provided. ```shell export subject="9818ea5e-30a8-4b52-879d-d34590e7250e" curl "http://localhost:4445/admin/oauth2/auth/sessions/consent?subject=$subject" ``` -------------------------------- ### Perform Authorization Code Grant Flow Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Initiates the authorization code grant flow for a client, simulating a frontend client like a mobile app. Requires login and consent. ```shell hydra perform authorization-code \ --client-id $CLIENT_ID \ --client-secret $CLIENT_SECRET \ --endpoint http://localhost:4444/ \ --port 5555 \ --scope read --scope write ``` -------------------------------- ### Set Environment Variables for Docker Compose Source: https://github.com/blinkbitcoin/blink/blob/main/quickstart/README.md Sets environment variables for HOST_PROJECT_PATH and COMPOSE_PROJECT_NAME using direnv to manage Docker Compose configurations. ```bash echo 'export HOST_PROJECT_PATH="$(pwd)"' >> .envrc echo 'export COMPOSE_PROJECT_NAME="$(basename $PWD)"' >> .envrc direnv allow ``` -------------------------------- ### GraphQL Query for Decisions Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Performs a GraphQL query to retrieve decision information, potentially related to sessions or access. ```shell curl -I -X POST http://localhost:4456/decisions/graphql -H "Oauth2-Token: $ory_at_TOKEN" ``` -------------------------------- ### Rollback Database Migrations Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Revert the last applied database migration using the migrate-mongo CLI, referencing the configuration file. ```bash # Rollback npx migrate-mongo down \ -f src/migrations/migrate-mongo-config.js ``` -------------------------------- ### Create API OAuth2 Client Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Creates an OAuth2 client named 'api' for the authorization code grant type. It sets specific redirect URIs and scopes, including 'openid'. ```shell code_client_app_=$(hydra create client \ --name "api" \ --endpoint http://localhost:4445 \ --grant-type authorization_code \ --response-type code,id_token \ --format json \ --scope read \ --scope write \ --scope openid \ --redirect-uri http://localhost:3001/keys/create/callback \ --skip-consent ) export CLIENT_ID_APP_API_KEY=$(echo $code_client_app_ | jq -r '.client_id') export CLIENT_SECRET_APP_API_KEY=$(echo $code_client_app_ | jq -r '.client_secret') ``` -------------------------------- ### Set API Key in Header Source: https://github.com/blinkbitcoin/blink/blob/main/core/api/spectaql/TUTORIAL.md Set your API key in the request header for custom requests. Ensure the key is prefixed with 'blink_'. ```http "X-API-KEY" "blink_..." ``` -------------------------------- ### Increase File Descriptor Limit Source: https://github.com/blinkbitcoin/blink/blob/main/docs/DEVELOPMENT_ENVIRONMENT.md This command allows you to increase the file descriptor limit. Replace `` with the desired number of file descriptors. This is often necessary for `buck2` to function correctly under heavy load. ```bash ulimit -n ``` -------------------------------- ### Set LND Debug Level to Critical Source: https://github.com/blinkbitcoin/blink/blob/main/docs/LEGACY_DEV.md Modify the LND configuration file to set the debug level to 'critical' to reduce disk usage from logs during integration testing. ```ini debuglevel=critical ``` -------------------------------- ### Create Dashboard OAuth2 Client Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Creates an OAuth2 client named 'dashboard' for the authorization code and refresh token grant types. It skips consent for trusted clients and sets specific redirect URIs and scopes. ```shell . ./.env code_client=$(hydra create client \ --name "dashboard" \ --endpoint http://localhost:4445 \ --grant-type authorization_code,refresh_token \ --response-type code,id_token \ --format json \ --scope offline \ --scope read \ --scope write \ --redirect-uri $NEXTAUTH_URL/api/auth/callback/blink \ --skip-consent ) export CLIENT_ID=$(echo $code_client | jq -r '.client_id') export CLIENT_SECRET=$(echo $code_client | jq -r '.client_secret') ``` -------------------------------- ### Define Account Status Enum via Object Constants Source: https://github.com/blinkbitcoin/blink/blob/main/CONTRIBUTING.md Demonstrates using a TypeScript object with 'as const' to create a type-safe enum-like structure. The corresponding declaration file type is derived from the object's keys and values. ```typescript // In implementation file export const AccountStatus = { Locked: "locked", Active: "active", } as const // In declaration file type AccountStatus = typeof import("./index").AccountStatus[keyof typeof import("./index").AccountStatus] ``` -------------------------------- ### Define Deposit Fee Calculator Object Source: https://github.com/blinkbitcoin/blink/blob/main/CONTRIBUTING.md Defines a TypeScript type for a deposit fee calculator with on-chain and lightning network fee methods. The implementation returns a concrete object adhering to this type. ```typescript // In '.d.ts' file type DepositFeeCalculator = { onChainDepositFee({ amount, ratio, }: OnChainDepositFeeArgs): BtcPaymentAmount | ValidationError lnDepositFee(): BtcPaymentAmount } // In implementation file export const DepositFeeCalculator = (): DepositFeeCalculator => { const onChainDepositFee = ({ amount, ratio }: onChainDepositFeeArgs) => { return ratio === 0 ? ZERO_SATS : checkedToBtcPaymentAmount(Math.round(Number(amount.amount) * ratio)) } return { onChainDepositFee, lnDepositFee: () => ZERO_SATS, // TODO: implement } } ``` -------------------------------- ### Test lnurlp Endpoint Source: https://github.com/blinkbitcoin/blink/blob/main/apps/pay/README.md Use curl to test the lnurlp endpoint for a given user. You can also specify an amount to test lnurlp with a predefined value. ```sh curl localhost:3000/.well-known/lnurlp/alice ``` ```sh curl localhost:3000/.well-known/lnurlp/alice?amount=1234 ``` -------------------------------- ### Import and Use External Library Types Source: https://github.com/blinkbitcoin/blink/blob/main/CONTRIBUTING.md Import types from external libraries to use them directly or to derive new types. This is useful for accessing nested properties or complex return types. ```typescript type GetPaymentResult = import("lightning").GetPaymentResult type RawPaths = NonNullable["paths"] ``` -------------------------------- ### Aggregate Transactions for Double Reimbursement Source: https://github.com/blinkbitcoin/blink/blob/main/core/api/src/debug/mongodb-query.txt This snippet groups transactions by '_original_journal' and counts them. It then filters for journals with a count greater than 2, which is used to identify potential double reimbursement issues. ```javascript db.getCollection('medici_transactions').aggregate([ {$group : { "_id": "$_original_journal" , count : { $sum: 1 }}}, // reimbursement is done on both transaction attached to the journal // so need to be more than 2 to match the "issue" {$match : { count : { $gt : 2 } }} ]) ``` -------------------------------- ### Request OAuth2 Logout Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Initiates an OAuth2 logout request. This endpoint is used to clear session information. ```bash curl http://localhost:4445/admin/oauth2/auth/requests/logout ``` -------------------------------- ### Delete All OAuth2 Sessions Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md This command deletes all OAuth2 sessions associated with a given subject and client ID. Ensure both subject and CLIENT_ID_APP_API_KEY are set. ```bash export subject=9818ea5e-30a8-4b52-879d-d34590e7250e curl -v -X DELETE "http://localhost:4445/admin/oauth2/auth/sessions/consent?subject=$subject&client=$CLIENT_ID_APP_API_KEY" ``` -------------------------------- ### Introspect Token via cURL Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Introspects a token using cURL POST request to the Hydra admin API. ```shell curl -X POST http://localhost:4445/admin/oauth2/introspect -d token=$ory_at_TOKEN ``` -------------------------------- ### Implement Function with Declared Argument Type Source: https://github.com/blinkbitcoin/blink/blob/main/CONTRIBUTING.md Define complex argument types in a declaration file and then assign them at the point of function implementation. This improves readability for functions with many arguments. ```typescript // in '.d.ts' file type MyFuncArgs = { myFirstArg: MyFirstArg mySecondArg: MySecondArg } // in other file const myFunction = async ({ myFirstArg, mySecondArg, }: MyFuncArgs): Promise => { return doThing(myFirstArg, mySecondArg) } ``` -------------------------------- ### Define Unique Symbol Types Source: https://github.com/blinkbitcoin/blink/blob/main/CONTRIBUTING.md Use unique symbol types to differentiate between primitives with the same underlying type but different meanings, such as addresses and payment requests. ```typescript type EncodedPaymentRequest = string & { readonly brand: unique symbol } type OnChainAddress = string & { readonly brand: unique symbol } ``` -------------------------------- ### Delete OAuth2 Token by Session ID Source: https://github.com/blinkbitcoin/blink/blob/main/docs/hydra.md Use this endpoint to revoke a specific OAuth2 token by its session ID. Ensure the session ID is correctly formatted. ```bash export session_id="b3fc4e84-4f73-4229-acdd-9bbaba00ca60" curl -v -X DELETE "http://localhost:4445/admin/oauth2/auth/sessions/login?sid=$session_id" ``` ```bash export subject=9818ea5e-30a8-4b52-879d-d34590e7250e curl -v -X DELETE "http://localhost:4445/admin/oauth2/auth/sessions/login?subject=$subject" ``` -------------------------------- ### Define Custom Error Types Source: https://github.com/blinkbitcoin/blink/blob/main/CONTRIBUTING.md Define custom error types that extend a base DomainError class. These are typically used in function signature type definitions. ```typescript export class LightningError extends DomainError { name = this.constructor.name } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.