Skip to content

Commit 97178b5

Browse files
sanducbmkurapov
andauthored
chore(backend, auth): use open-payments-specifications as submodule (#3615)
* chore: add open-payments-specifications submodule (v1.0.3) and load specs via @interledger/openapi createOpenAPI * chore: format * fix: attempt to fix CI fetching of submodule * fix(ci): add submodule to .prettierignore * chore(backend): copy specs for token introspection, update readmes * chore(backend): update lock file * fix: attempt to fix ci * fix: attempt to fix ci * fix: attempt to fix ci * fix: attempt to fix ci * fix: attempt to fix ci * fix: attempt to fix ci * fix: revert refs in token introspection * chore(token-introspection): remove copy script for OP specs * chore(ci): remove submodules fetch * chore(token-introspection): remove duplicate spec file * fix(token-introspection): update spec path Co-authored-by: Max Kurapov <[email protected]> * chore(token-introspection): generate types --------- Co-authored-by: Max Kurapov <[email protected]>
1 parent 41259a4 commit 97178b5

File tree

15 files changed

+343
-552
lines changed

15 files changed

+343
-552
lines changed

.github/workflows/node-build.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
timeout-minutes: 25
2828
steps:
2929
- uses: actions/checkout@v4
30+
with:
31+
submodules: recursive
32+
fetch-depth: 0
3033
- uses: ./.github/workflows/rafiki/env-setup
3134
- run: pnpm --filter backend build:deps
3235
- run: NODE_OPTIONS="--max-old-space-size=4096" pnpm --filter backend test:ci
@@ -53,6 +56,9 @@ jobs:
5356
timeout-minutes: 5
5457
steps:
5558
- uses: actions/checkout@v4
59+
with:
60+
submodules: recursive
61+
fetch-depth: 0
5662
- uses: ./.github/workflows/rafiki/env-setup
5763
- run: pnpm --filter auth build:deps
5864
- run: pnpm --filter auth test
@@ -143,6 +149,9 @@ jobs:
143149
steps:
144150
- name: Checkout code
145151
uses: actions/checkout@v4
152+
with:
153+
submodules: recursive
154+
fetch-depth: 0
146155

147156
- name: Setup environment
148157
uses: ./.github/workflows/rafiki/env-setup
@@ -166,6 +175,9 @@ jobs:
166175
steps:
167176
- name: Checkout code
168177
uses: actions/checkout@v4
178+
with:
179+
submodules: recursive
180+
fetch-depth: 0
169181

170182
- name: Setup environment
171183
uses: ./.github/workflows/rafiki/env-setup
@@ -396,6 +408,8 @@ jobs:
396408
- backend
397409
- frontend
398410
steps:
411+
- name: Checkout code
412+
uses: actions/checkout@v4
399413
- name: Set up Docker Buildx
400414
uses: docker/setup-buildx-action@v3
401415
- name: Build

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "open-payments-specifications"]
2+
path = open-payments-specifications
3+
url = https://github.com/interledger/open-payments-specifications.git

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ build
1414
**/styles/*.css
1515
.docusaurus
1616
.cache-loader
17-
.astro
17+
.astro
18+
open-payments-specifications/**

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Clone the Rafiki repository
6767
```sh
6868
git clone https://github.com/interledger/rafiki.git
6969
cd rafiki
70+
git submodule update --init --recursive
7071
```
7172

7273
Install Node.js
@@ -94,6 +95,22 @@ Install dependencies
9495
pnpm i
9596
```
9697

98+
### Git submodules
99+
100+
This repository uses a git submodule for Open Payments specifications located at `open-payments-specifications/`.
101+
102+
- Initialize submodules after cloning:
103+
104+
```sh
105+
git submodule update --init --recursive
106+
```
107+
108+
- Alternatively, clone the repository with submodules in one step:
109+
110+
```sh
111+
git clone --recurse-submodules https://github.com/interledger/rafiki.git
112+
```
113+
97114
### Local Development
98115

99116
The Rafiki local environment is the best way to explore Rafiki locally. The [localenv](localenv) directory contains instructions for setting up a local playground. Please refer to the README for each individual package for more details.

localenv/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ Remove volumes and images
7979
pnpm localenv:compose down --volumes --rmi all
8080
```
8181

82+
### Note on git submodules
83+
84+
Rafiki uses a git submodule for Open Payments specifications (`open-payments-specifications/`). Ensure submodules are initialized before building or running the Local Playground:
85+
86+
```sh
87+
git submodule update --init --recursive
88+
```
89+
90+
Alternatively, clone the repository with submodules in one step:
91+
92+
```sh
93+
git clone --recurse-submodules https://github.com/interledger/rafiki.git
94+
```
95+
8296
# Environment components
8397

8498
![Docker compose environment](../packages/documentation/public/img/localenv.png)

open-payments-specifications

packages/auth/Dockerfile.prod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ FROM base AS builder
3535
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./
3636
COPY packages/auth ./packages/auth
3737
COPY packages/token-introspection ./packages/token-introspection
38+
COPY open-payments-specifications/openapi ./open-payments-specifications/openapi
3839

3940
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
4041
pnpm install \
@@ -59,6 +60,7 @@ COPY --from=prod-deps /home/rafiki/packages/auth/knexfile.js ./packages/auth/kne
5960
COPY --from=builder /home/rafiki/packages/auth/migrations/ ./packages/auth/migrations
6061
COPY --from=builder /home/rafiki/packages/auth/dist ./packages/auth/dist
6162
COPY --from=builder /home/rafiki/packages/token-introspection/dist ./packages/token-introspection/dist
63+
COPY --from=builder /home/rafiki/open-payments-specifications/openapi ./open-payments-specifications/openapi
6264

6365
USER root
6466

packages/auth/src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ import { createAccessTokenRoutes } from './accessToken/routes'
1414
import { createGrantRoutes } from './grant/routes'
1515
import { createInteractionRoutes } from './interaction/routes'
1616
import { createOpenAPI } from '@interledger/openapi'
17-
import {
18-
createUnauthenticatedClient as createOpenPaymentsClient,
19-
getAuthServerOpenAPI
20-
} from '@interledger/open-payments'
17+
import { createUnauthenticatedClient as createOpenPaymentsClient } from '@interledger/open-payments'
2118
import { createInteractionService } from './interaction/service'
2219
import { getTokenIntrospectionOpenAPI } from 'token-introspection'
2320
import { Redis } from 'ioredis'
@@ -187,7 +184,12 @@ export function initIocContainer(
187184
)
188185

189186
container.singleton('openApi', async () => {
190-
const authServerSpec = await getAuthServerOpenAPI()
187+
const authServerSpec = await createOpenAPI(
188+
path.resolve(
189+
__dirname,
190+
'../../../open-payments-specifications/openapi/auth-server.yaml'
191+
)
192+
)
191193
const idpSpec = await createOpenAPI(
192194
path.resolve(__dirname, './openapi/specs/id-provider.yaml')
193195
)

packages/backend/Dockerfile.prod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ FROM base AS builder
3535
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./
3636
COPY packages/backend ./packages/backend
3737
COPY packages/token-introspection ./packages/token-introspection
38+
COPY open-payments-specifications/openapi ./open-payments-specifications/openapi
3839

3940
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
4041
pnpm install \
@@ -60,6 +61,7 @@ COPY --from=builder /home/rafiki/packages/backend/migrations/ ./packages/backend
6061
COPY --from=builder /home/rafiki/packages/backend/dist ./packages/backend/dist
6162
COPY --from=builder /home/rafiki/packages/token-introspection/dist ./packages/token-introspection/dist
6263
COPY --from=builder /home/rafiki/packages/backend/knexfile.js ./packages/backend/knexfile.js
64+
COPY --from=builder /home/rafiki/open-payments-specifications/openapi ./open-payments-specifications/openapi
6365

6466
USER root
6567

packages/backend/src/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import net from 'net'
99
import dns from 'dns'
1010
import { createHmac } from 'crypto'
1111

12-
import {
13-
createAuthenticatedClient as createOpenPaymentsClient,
14-
getResourceServerOpenAPI,
15-
getWalletAddressServerOpenAPI
16-
} from '@interledger/open-payments'
12+
import { createAuthenticatedClient as createOpenPaymentsClient } from '@interledger/open-payments'
13+
import { createOpenAPI } from '@interledger/openapi'
14+
import path from 'path'
1715
import { StreamServer } from '@interledger/stream-receiver'
1816
import axios from 'axios'
1917
import {
@@ -301,8 +299,18 @@ export function initIocContainer(
301299
})
302300

303301
container.singleton('openApi', async () => {
304-
const resourceServerSpec = await getResourceServerOpenAPI()
305-
const walletAddressServerSpec = await getWalletAddressServerOpenAPI()
302+
const resourceServerSpec = await createOpenAPI(
303+
path.resolve(
304+
__dirname,
305+
'../../../open-payments-specifications/openapi/resource-server.yaml'
306+
)
307+
)
308+
const walletAddressServerSpec = await createOpenAPI(
309+
path.resolve(
310+
__dirname,
311+
'../../../open-payments-specifications/openapi/wallet-address-server.yaml'
312+
)
313+
)
306314

307315
return {
308316
resourceServerSpec,

0 commit comments

Comments
 (0)