Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldocapurro authored Dec 9, 2024
0 parents commit 351a061
Show file tree
Hide file tree
Showing 39 changed files with 5,430 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/relyance-sci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Relyance SCI Scan

on:
schedule:
- cron: "0 20 * * *"
workflow_dispatch:

jobs:
execute-relyance-sci:
name: Relyance SCI Job
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Pull and run SCI binary
run: |-
docker pull gcr.io/relyance-ext/compliance_inspector:release && \
docker run --rm -v `pwd`:/repo --env API_KEY='${{ secrets.DPP_SCI_KEY }}' gcr.io/relyance-ext/compliance_inspector:release
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.17.0
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# React example of minikit

Apart from a frontend, you'll need a backend, this template contains an example of that as well

## To run, install:

- deps, `cd frontend;pnpm i;cd -;cd backend;pnpm i`
- ngrok - Create a free ngrok account, follow the official [docs](https://ngrok.com/docs/getting-started/)
- nginx - use you favorite package manager :)

### nginx setup

To serve multiple localhost applications through a single ngrok tunnel (only one available for free-tier users), you can use nginx as a reverse proxy. Follow the steps below to set it up:

### Run nginx

Use the config provided in the root of this repo
`sudo nginx -c full/path/to/this/repo/nginx.conf`
or, if you run the command from the root dir
`sudo nginx -c $(pwd)/nginx.conf`

To stop nginx run `sudo nginx -s stop`

### Tunnel through Ngrok

`ngrok http 8080`
The port doesn't matter, make sure it's the `listen` one from nginx config
4 changes: 4 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WLD_CLIENT_ID=
WLD_CLIENT_SECRET=
# needed by authjs, use `openssl rand -base64 32` to generate
AUTH_SECRET=
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules

.env
1 change: 1 addition & 0 deletions backend/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.17.0
3 changes: 3 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### To get started, start the server

`pnpm run dev`
37 changes: 37 additions & 0 deletions backend/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import express from "express";

import { verifyHandler } from "./src/verify";
import { initiatePaymentHandler } from "./src/initiate-payment";
import { confirmPaymentHandler } from "./src/confirm-payment";
import cors from "cors";

const app = express();

// trust the proxy to allow HTTPS protocol to be detected
// https://expressjs.com/en/guide/behind-proxies.html
app.set("trust proxy", true);
// allow cors
app.use(cors());
// json middleware
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// request logger middleware
app.use((req, _res, next) => {
console.log(`logger: ${req.method} ${req.url}`);
next();
});

app.get("/ping", (_, res) => {
res.send("minikit-example pong v1");
});

// protected routes
app.post("/verify", verifyHandler);
app.post("/initiate-payment", initiatePaymentHandler);
app.post("/confirm-payment", confirmPaymentHandler);

const port = 3000; // use env var
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
5 changes: 5 additions & 0 deletions backend/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"watch": ["./src/**/*.ts", "./index.ts"],
"ext": "ts",
"exec": "ts-node ./index.ts"
}
28 changes: 28 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "example-minikit-server",
"version": "0.0.0",
"description": "",
"main": "index.ts",
"type": "module",
"scripts": {
"dev": "tsx watch --env-file=./.env --clear-screen=false ./index.ts | pino-pretty",
"a": "tsx --help"
},
"dependencies": {
"@worldcoin/minikit-js": "1.1.1",
"cors": "^2.8.5",
"express": "^4.21.0",
"node-fetch": "^3.3.2",
"pino-pretty": "^11.0.0",
"tsx": "^4.7.2"
},
"devDependencies": {
"@types/express": "5.0.0",
"@types/node": "20",
"ts-node": "10.7.0",
"typescript": "5.6.2"
},
"engines": {
"node": ">=16"
}
}
Loading

0 comments on commit 351a061

Please sign in to comment.