jnewc / primer-example-backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Primer Banner

πŸ’³ Primer Example Backend

This project is a very simple companion backend to the example apps of Primer Universal Checkout:


This server uses Node as the runtime (v16 to be compatible with Glitch) and Fastify as the HTTP server framework.

πŸš€ Get started

Pre-requisites

  • A Primer sandbox account πŸ‘€

  • An API key for your Sandbox πŸ”‘
    You can grab your API key or create a new one from the Primer Dashboard.

Deploy on Glitch ⚑️

We recommend using Glitch to quickly spin up a new instance of your server for free.

  1. First, click on this button to open the project in Glitch and start the server.
    It may take a moment to start.

    Remix With Glitch

  2. On Glitch, open the file .env.
    Set the environment variable PRIMER_API_KEY to your Primer sandbox API key.

  3. On Glitch, grab the URL of your Glitch instance.
    It should look like https://xxx-yyy-zzz.glitch.me.

  4. Paste your Glitch instance URL in the example project.

Run it locally

  1. First, make sure Node is installed on your machine.

  2. Clone this repository:

    git clone https://github.com/primer-io/example-backend.git
    
    cd ./example-backend
  3. Install the dependencies:

    npm install
  4. Clone the file .env.example and call it .env. Set the environment variable PRIMER_API_KEY to your Primer sandbox API key.

  5. Execute the following script on a terminal window:

    npm start

πŸ€– Capabilities

  • GET /
    Health check

  • POST /client-session
    Create a client session

About


Languages

Language:TypeScript 100.0%