...

Text file src/edge-infra.dev/pkg/edge/api/README.md

Documentation: edge-infra.dev/pkg/edge/api

     1# EDGE API Server
     2
     3### Structure
     4
     5api
     6 - apierror: api error package with different utilities for creating and using different api errors
     7 - bsl: everything bsl related for api server
     8   - types: go types for calling bsl apis
     9 - clients: clients specific to api
    10 - graph: all code related to running the gql gen graphql api
    11   - generated: generated code from the gqlgen plugin
    12   - mapper: mapper functions to map to and from gqlgen models
    13   - model: model for graphql types generated by gqlgen
    14   - resolver: generated code to wire up logic for each graphql query and mutation
    15   - schema: the graphql schema used to generate the gql gen server
    16   - setup: code for setting up and running the gql server
    17   - test: test utilities for graph package
    18   - utils: helper utilities for working with graphql
    19 - middleware: middleware added to the graphql server for things like auth and validation
    20 - mocks: service and client mocks for unit testing
    21 - services: logic for resolvers
    22 - sql: code to interact with sql
    23 - **testutils**: some helpers for unit testing (need to work to refactor)
    24 - totp: code related to totp functionality
    25 - **types**: Need to refactor types to be with clients or with whatever is using them
    26 - **utils**: refactor into better place (separate libraries, mapper, etc)
    27
    28### How to run Edge API
    29- Go into `cmd/edge/api`, create an `.env` file:
    30```
    31touch .env
    32```
    33- Here is the template of how that file will look:
    34
    35```
    36APP_ENV="local-dev"
    37PORT=5000
    38APP_SECRET="SUPER_SECRET_SECRET"
    39BSP_ENDPOINT="https://api.ncr.com"
    40BSP_ROOT="/customers/"
    41BSP_SITE_ENDPOINT="https://api.ncr.com"
    42BSP_ORGANIZATION_PREFIX="edge-dev1"
    43TOP_LEVEL_PROJECT_ID="ret-edge-dev1-foreman"
    44INTEGRATION_TEST=false
    45GOOGLE_APPLICATION_CREDENTIALS="SERVICE_ACCOUNT_KEY"
    46SQL_CONNECTION_NAME="ret-edge-dev1-foreman:us-central1:edge-dev1"
    47SQL_USER="bff-sa@ret-edge-dev1-foreman.iam"
    48SQL_DB_NAME="edge-dev1"
    49BSL_ORG="edge-dev1-retail-b526aa"
    50BSP_RESET_URL="https://dev1.edge-preprod.dev/reset-password"
    51OKTA_ISSUER="https://login.ncr.com/oauth2/default"
    52OKTA_CLIENT_ID="0oa4znv55ixacgyLx697"
    53PS_BQ_TABLE="ret-edge-dev1-foreman.ctlfishpubsub.resources"
    54```
    55
    56- ***To acquire all the credentioals you need for this file, please reach out to the API team, and we will send you the proper values for your `.env` file and service accounts ***
    57  
    58- After acquiring the input, paste them inside ur `.env` file and save. 
    59
    60- To run `Edge API`, run the following command
    61```
    62go run cmd/edge/api/server.go
    63```
    64
    65- If the `Edge API` ran successfully, you will get this message:
    66```
    67{"level":"warn","error":"unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined","time":"2023-11-01T14:41:18-04:00","message":"failed to load in-cluster config, attempting to use local kubeconfig"}
    68{"severity":"INFO","time":"2023-11-01T14:41:21-04:00","message":"connect to http://localhost:8080/graphiql/ for GraphiQL","version":"dev","logging.googleapis.com/sourceLocation":{"function":"edge-infra.dev/pkg/edge/api/graph/setup.Server","file":"/Users/QLID/edge-infra/pkg/edge/api/graph/setup/bff_setup.go","line":247}}
    69```
    70
    71- Then go to your browser, type `http://localhost:8080/graphiql/`

View as plain text