Skip to content

Submissions api integration #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 6, 2025
Merged
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
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ KAFKA_DLQ_MAX_RETRIES=3
# API configs
BUS_API_URL="https://api.topcoder-dev.com/v5/bus/events"
CHALLENGE_API_URL="https://api.topcoder-dev.com/v5/challenges/"
RESOURCE_API_URL="https://api.topcoder-dev.com/v6/"
MEMBER_API_URL="https://api.topcoder-dev.com/v5/members"
# M2m configs
M2M_AUTH_URL="https://auth0.topcoder-dev.com/oauth/token"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ pids

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
uploads/*
!uploads/artifact-123.zip
!uploads/submission-123.zip
50 changes: 50 additions & 0 deletions mock/jwt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as jwt from 'jsonwebtoken';
import { Scope } from '../src/shared/enums/scopes.enum';
import { UserRole } from '../src/shared/enums/userRole.enum';

const commonFields = {
exp: 1845393226,
iss: 'https://topcoder-dev.com'
};

const authSecret = 'secret';

const adminPayload = {
roles: [UserRole.Admin],
handle: 'admin',
userId: 123,
...commonFields
};

console.log('------------- Admin Token -------------');
console.log(jwt.sign(adminPayload, authSecret));

const m2mPayload = {
scope: `${Scope.AllReview} ${Scope.AllSubmission} ${Scope.AllAppeal} ${Scope.AllReviewSummation}`,
sub: 'auth0|clients',
...commonFields
};

console.log('------------- Full M2M token -------------');
console.log(jwt.sign(m2mPayload, authSecret));

const userPayload = {
roles: [UserRole.User],
handle: 'user',
userId: 124,
...commonFields
};

console.log('------------- User Token -------------');
console.log(jwt.sign(userPayload, authSecret));


const reviewerPayload = {
roles: [UserRole.Reviewer],
handle: 'reviewer',
userId: 125,
...commonFields
};

console.log('------------- Reviewer Token -------------');
console.log(jwt.sign(reviewerPayload, authSecret));
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"postinstall": "npx prisma generate"
"postinstall": "pnpm exec prisma generate"
},
"dependencies": {
"@nestjs/axios": "^4.0.0",
Expand All @@ -36,6 +36,8 @@
"cors": "^2.8.5",
"jsonwebtoken": "^9.0.2",
"jwks-rsa": "^3.2.0",
"lodash": "^4.17.21",
"multer": "^2.0.1",
"nanoid": "~5.1.2",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
Expand All @@ -52,6 +54,7 @@
"@swc/core": "^1.10.7",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.14",
"@types/multer": "^1.4.13",
"@types/node": "^22.10.7",
"@types/supertest": "^6.0.2",
"eslint": "^9.18.0",
Expand All @@ -73,7 +76,8 @@
"winston": "^3.17.0"
},
"prisma": {
"seed": "ts-node prisma/migrate.ts"
"seed": "ts-node prisma/migrate.ts",
"seed222": "ts-node prisma/seed.ts"
},
"jest": {
"moduleFileExtensions": [
Expand Down
42 changes: 42 additions & 0 deletions pnpm-lock.yaml

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

Loading