Skip to content

Commit

Permalink
Merge pull request #1 from primer-io/u/at/clean
Browse files Browse the repository at this point in the history
Clean
  • Loading branch information
xevious78 authored Jan 8, 2024
2 parents 9292202 + 26310ab commit 55b06c6
Show file tree
Hide file tree
Showing 17 changed files with 2,006 additions and 153 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
API_KEY=
# API key of your environment
PRIMER_API_KEY=

24 changes: 0 additions & 24 deletions .github/workflows/lint.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist
node_modules

.env
.env
.DS_Store
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
68 changes: 54 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,64 @@
# Server Deno Hono
![Primer Banner](https://github.com/primer-io/example-backend/raw/main/images/primer-banner.png)

In this example we build a server to integrate with Primer's API.
# 💳 Primer Example Backend

It uses [Deno](https://deno.land) as the runtime and [Hono](https://hono.dev) as the HTTP server framework, but feel free to build your server however you'd like.
This project is a very simple companion backend to the example apps of [Primer](https://primer.io) Universal Checkout:

## Running on your browser
- [Example iOS apps](https://github.com/primer-io/checkout-examples-ios)
- [Example Android apps](https://github.com/primer-io/checkout-examples-android)

[Click here to immediately launch it on your browser](https://stackblitz.com/github/primer-io/checkout-web/tree/main/examples/server-deno-hono).
---

Once it's open, make sure to:
_This server uses [Node](https://nodejs.org/) as the runtime (v16 to be compatible with Glitch) and [Fastify](https://fastify.dev/) as the HTTP server framework._

1. Create a new file `.env` and copy contents from `.env.example` into it
2. Get an `API_KEY` from your Primer Dashboard and paste it there
- Example: `API_KEY=1234-foo-bar-4321`
# 🚀 Get started

## Running locally
## Pre-requisites

- A Primer sandbox account 👤

- An API key for your Sandbox 🔑 <br /> You can grab your API key or create a new one from the [Primer Dashboard](https://sandbox-dashboard.primer.io/developers/apiKeys).

## 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. <br /> _It may take a moment to start._

[![Remix With Glitch](https://cdn.glitch.com/2703baf2-b643-4da7-ab91-7ee2a2d00b5b%2Fremix-button-v2.svg?v=1622676640618)](https://glitch.com/edit/#!/import/github/primer-io/example-backend)

2. On Glitch, open the file `.env`. <br /> Set the environment variable `PRIMER_API_KEY` to your Primer sandbox API key.

3. On Glitch, grab the URL of your Glitch instance. <br /> 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](https://nodejs.org) is installed on your machine.
2. Clone this repository:

1. Install [Deno](https://deno.land)
2. Follow the same instructions described on the section above about the `API_KEY`
3. Execute the following script on a terminal window:
```sh
deno task start
git clone https://github.com/primer-io/example-backend.git

cd ./example-backend
```

3. Install the dependencies:

```sh
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:
```sh
npm start
```

# 🤖 Capabilities

- `GET /` <br /> Health check

- `POST /client-session` <br /> Create a client session
Binary file removed bun.lockb
Binary file not shown.
9 changes: 0 additions & 9 deletions deno.json

This file was deleted.

40 changes: 0 additions & 40 deletions deno.lock

This file was deleted.

Binary file added images/primer-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 55b06c6

Please sign in to comment.