Narcissistic Piano Mover

    @newskit-render/api
    TypeScript icon, indicating that this package has built-in type declarations

    0.32.0 • Public • Published

    @newskit-render/api

    Helper package to make setting up and using Apollo Client with Main or NewsKit API easier.

    Usage

    createApolloClient

    import { createApolloClient, ClientTypes } from '@newskit-render/api'
    
    // MAIN with cookies
    const mainApolloClient = await createApolloClient(
      ClientTypes.main,
      context.req.headers.cookie
    )
    
    // NKAPI with cookies
    const nkApiApolloClient = await createApolloClient(
      ClientTypes.nkapi,
      context.req.headers.cookie
    )
    
    // NKAPI without cookies
    const apolloClient = await createApolloClient(ClientTypes.nkapi)
    
    // pass custom set up
    const apolloClient = await createApolloClient({
      initialState: {},
      uri: process.env.NEWSKIT_API_ENV_URL,
      headers: {
        'x-api-key': process.env.NEWSKIT_API_X_API_KEY,
      },
      addTypename: false,
    })
    

    getApolloClient

    import { getApolloClient } from '@newskit-render/api'
    
    const shouldUseNewskitApi = true
    
    const apolloClient = await getApolloClient(
      shouldUseNewskitApi,
      req.headers.cookie
    )
    

    helpers

    1. getHeaders - creates header for MAIN
    2. getAccessToken - access header used by MAIN
    3. getMainSession - get MAIN session from cookie
    4. sessionParser - decodes session id

    Authentication environment variables

    For MAIN and NewsKit API authentication see MAIN and NewsKit API

    Keywords

    none

    Install

    npm i @newskit-render/api

    DownloadsWeekly Downloads

    246

    Version

    0.32.0

    License

    UNLICENSED

    Unpacked Size

    77.3 kB

    Total Files

    80

    Last publish

    Collaborators

    • newskit