Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 74 additions & 8 deletions Backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions Backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@
"test:e2e": "jest --config ./test/jest-e2e.json",
"migration:run": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d src/database/data-source.ts migration:run",
"migration:revert": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d src/database/data-source.ts migration:revert",
"migration:generate": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d src/database/data-source.ts migration:generate"
"migration:generate": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d src/database/data-source.ts migration:generate",
"export-spec": "ts-node -r tsconfig-paths/register src/export-spec.ts"
},
"dependencies": {
"@nestjs/common": "^11.0.1",
"@nestjs/config": "^4.0.3",
"@nestjs/core": "^11.0.1",
"@nestjs/mapped-types": "^2.1.0",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.2.6",
"@nestjs/throttler": "^6.4.0",
"@nestjs/typeorm": "^11.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.2",
"cookie-parser": "^1.4.7",
"csrf": "^3.1.0",
"ethers": "^6.15.0",
"js-yaml": "^5.0.0",
"pg": "^8.13.3",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"typeorm": "^0.3.28",
"@nestjs/throttler": "^6.4.0",
"@nestjs/swagger": "^11.2.6",
"cookie-parser": "^1.4.7",
"csrf": "^3.1.0"
"typeorm": "^0.3.28"
},
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
Expand All @@ -52,6 +54,7 @@
"@types/express": "^5.0.0",
"@types/geojson": "^7946.0.16",
"@types/jest": "^29.5.14",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.10.7",
"@types/supertest": "^6.0.2",
"eslint": "^9.18.0",
Expand Down Expand Up @@ -86,4 +89,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
35 changes: 35 additions & 0 deletions Backend/src/export-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { writeFileSync, mkdirSync } from 'fs';
import { join } from 'path';
import { dump } from 'js-yaml';
import { AppModule } from './app.module';

const docsDir = join(__dirname, '..', '..', 'infrastructure', 'docs');

(async () => {

Check warning on line 10 in Backend/src/export-spec.ts

View workflow job for this annotation

GitHub Actions / Backend (NestJS)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
try {
const app = await NestFactory.create(AppModule, { logger: false });
await app.init();

const swaggerConfig = new DocumentBuilder()
.setTitle('Gist API')
.setDescription('Anonymous hyperlocal messaging on Stellar')
.setVersion('0.1.0')
.build();

const document = SwaggerModule.createDocument(app, swaggerConfig);

mkdirSync(docsDir, { recursive: true });
writeFileSync(
join(docsDir, 'openapi.json'),
JSON.stringify(document, null, 2),
);
writeFileSync(join(docsDir, 'openapi.yaml'), dump(document));

await app.close();
} catch (error) {
console.error(error);
process.exit(1);
}
})();
39 changes: 39 additions & 0 deletions infrastructure/ci/docs-generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,56 @@ jobs:
generate-api-docs:
name: API Docs
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: vertexchain_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: Backend/package-lock.json

- name: Install Backend dependencies
run: cd Backend && npm ci

- name: Generate OpenAPI and static docs
env:
DATABASE_HOST: localhost
DATABASE_PORT: 5432
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_NAME: vertexchain_test
run: |
version="${{ github.event.release.tag_name }}"
if [ -z "$version" ]; then version="$(date +%Y.%m.%d)"; fi
bash infrastructure/scripts/generate-api-docs.sh "$version"

- name: Upload OpenAPI spec artifact
uses: actions/upload-artifact@v4
with:
name: openapi-spec
path: |
infrastructure/docs/openapi.json
infrastructure/docs/openapi.yaml
if-no-files-found: error

- name: Commit API docs
run: |
git config user.name "github-actions[bot]"
Expand Down
Loading
Loading