Skip to content

remove resource call to v4 challenge api #14

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

Closed
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ if not provided, then SSL connection is not used, direct insecure connection is
- TOKEN_CACHE_TIME: Cache time of M2M token, optional
- AUTH0_CLIENT_ID: Auth0 client id for M2M token
- AUTH0_CLIENT_SECRET: Auth0 client secret for M2M token
- IS_CREATE_FORUM: Should create forum resource or not
- CHALLENGE_ORIGINATOR: originator from challenge service
- CHALLENGE_USER_UNREGISTRATION_TOPIC: unregistration topic from challenge service
- CHALLENGE_USER_REGISTRATION_TOPIC: registration topic from challenge service

Also note that there is a `/health` endpoint that checks for the health of the app. This sets up an expressjs server and listens on the environment variable `PORT`. It's not part of the configuration file and needs to be passed as an environment variable

Expand Down
33 changes: 15 additions & 18 deletions challenge-api-v5-mock/mock-challenge-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,36 @@ const http = require('http')
const send = require('http-json-response')
const _ = require('lodash')


// Sample challenge
const sampleChallenge = {
"id": "96059e8d-4761-4978-9a14-c86ae6b971c3",
"legacyId": 30049360,
"type": "Code",
"track": "Develop",
"name": "Test Challenge 1",
"description": "Test Challenge 1 - Description",
"challengeSettings": [
'id': '96059e8d-4761-4978-9a14-c86ae6b971c3',
'legacyId': 30049360,
'type': 'Code',
'track': 'Develop',
'name': 'Test Challenge 1',
'description': 'Test Challenge 1 - Description',
'challengeSettings': [
{
"type": "setting1",
"value": "value1"
'type': 'setting1',
'value': 'value1'
}
],
"created": "2019-03-02T14:35:53.948Z",
"createdBy": "Copilot1",
"updated": "2019-03-02T14:35:53.948Z",
"updatedBy": "Copilot1"
'created': '2019-03-02T14:35:53.948Z',
'createdBy': 'Copilot1',
'updated': '2019-03-02T14:35:53.948Z',
'updatedBy': 'Copilot1'
}


const responses = {
'/v5/challenges/96059e8d-4761-4978-9a14-c86ae6b971c3': sampleChallenge
}

const mockChallengeV5Api = http.createServer((req, res) => {

if (req.method === 'GET' && _.includes(Object.keys(responses), req.url)) {
if (req.method === 'GET' && _.includes(Object.keys(responses), req.url)) {
return send(res, 200, responses[req.url])
} else {
// 404 for other routes
return send(res, 404, {message : 'Challenge not found'})
return send(res, 404, {message: 'Challenge not found'})
}
})

Expand Down
25 changes: 23 additions & 2 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,38 @@ module.exports = {

SUBMITTER_ROLE_ID: process.env.SUBMITTER_ROLE_ID || '732339e7-8e30-49d7-9198-cccf9451e221',

IS_CREATE_FORUM: process.env.IS_CREATE_FORUM || true,

CREATE_CHALLENGE_RESOURCE_TOPIC: process.env.CREATE_CHALLENGE_RESOURCE_TOPIC || 'challenge.action.resource.create',
DELETE_CHALLENGE_RESOURCE_TOPIC: process.env.DELETE_CHALLENGE_RESOURCE_TOPIC || 'challenge.action.resource.delete',

CHALLENGE_ORIGINATOR: process.env.CHALLENGE_ORIGINATOR || 'app.challenge.service',
CHALLENGE_USER_UNREGISTRATION_TOPIC: process.env.CHALLENGE_USER_UNREGISTRATION_TOPIC || 'notifications.kafka.queue.java.test',
CHALLENGE_USER_REGISTRATION_TOPIC: process.env.CHALLENGE_USER_REGISTRATION_TOPIC || 'notifications.kafka.queue.java.test',

CHALLENGE_API_V4_URL: process.env.CHALLENGE_API_V4_URL || 'https://api.topcoder-dev.com/v4/challenges',
CHALLENGE_API_V5_URL: process.env.CHALLENGE_API_V5_URL || 'http://localhost:3001/v5/challenges',
RESOURCE_ROLE_API_URL: process.env.RESOURCE_ROLE_API_URL || 'https://api.topcoder-dev.com/v5/resource-roles',

AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token', // Auth0 credentials for M2M token
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE || 'https://m2m.topcoder-dev.com/',
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID || 'e6oZAxnoFvjdRtjJs1Jt3tquLnNSTs0e',
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET || 'invalid',
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL || 'https://topcoder-dev.auth0.com/oauth/token',
TOKEN_CACHE_TIME: 90
TOKEN_CACHE_TIME: 90,

INFORMIX: {
SERVER: process.env.INFORMIX_SERVER || 'informixoltp_tcp', // informix server
DATABASE: process.env.INFORMIX_DATABASE || 'tcs_catalog', // informix database
HOST: process.env.INFORMIX_HOST || 'localhost', // host
PROTOCOL: process.env.INFORMIX_PROTOCOL || 'onsoctcp',
PORT: process.env.INFORMIX_PORT || '2021', // port
DB_LOCALE: process.env.INFORMIX_DB_LOCALE || 'en_US.57372',
USER: process.env.INFORMIX_USER || 'informix', // user
PASSWORD: process.env.INFORMIX_PASSWORD || '1nf0rm1x', // password
POOL_MAX_SIZE: parseInt(process.env.MAXPOOL, 10) || 60,
maxsize: parseInt(process.env.MAXSIZE) || 0,
minpool: parseInt(process.env.MINPOOL, 10) || 1,
idleTimeout: parseInt(process.env.IDLETIMEOUT, 10) || 3600,
timeout: parseInt(process.env.TIMEOUT, 10) || 30000
}
}
55 changes: 46 additions & 9 deletions docker/Dockerfile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
# Use the base image with Node.js 10.15-jessie
FROM node:10.15-jessie
FROM ibmcom/informix-innovator-c:12.10.FC12W1IE

# Copy the current directory into the Docker image
COPY . /legacy-resources-processor
ARG servername=informix

# Set working directory for future use
WORKDIR /legacy-resources-processor
USER root
RUN mkdir /app
WORKDIR /home/informix

# Install the dependencies from package.json
RUN npm install
CMD npm run start
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo "deb http://ftp.debian.org/debian/ stretch main non-free contrib" >/etc/apt/sources.list && \
echo "deb http://security.debian.org/ stretch/updates main contrib non-free" >>/etc/apt/sources.list

RUN apt-get -qq update && \
apt-get -qq install -y wget gcc-6 g++-6 make xz-utils python2.7 git curl

RUN wget -q -O node10.tar.xz https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz \
&& tar xfJ node10.tar.xz && rm -rf node10.tar.xz

ENV SERVERNAME=$servername

COPY docker/esql /opt/ibm/informix/bin/

RUN chmod +x /opt/ibm/informix/bin/esql
RUN echo "informixoltp_tcp onsoctcp $SERVERNAME sqlexec" \
> /opt/ibm/informix/etc/sqlhosts.informixoltp_tcp

ENV INFORMIXDIR /opt/ibm/informix
ENV INFORMIX_HOME /home/informix
ENV INFORMIXSERVER informixoltp_tcp
ENV INFORMIXTERM terminfo
ENV CLIENT_LOCALE=en_US.utf8
ENV DB_LOCALE=en_US.utf8
ENV DBDATE Y4MD-
ENV DBDELIMITER "|"
ENV PATH /home/informix/node-v10.15.1-linux-x64/bin:${INFORMIXDIR}/bin:${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${PATH}
ENV LD_LIBRARY_PATH ${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${INFORMIXDIR}/lib/cli
ENV INFORMIXSQLHOSTS /opt/ibm/informix/etc/sqlhosts.informixoltp_tcp
ENV USER root
ENV LICENSE accept

RUN ln -s /usr/bin/python2.7 /usr/bin/python
RUN echo "sqlexec 2021/tcp" >> /etc/services

COPY . /app

WORKDIR /app
RUN rm -rf node_modules && npm install --unsafe-perm

ENTRYPOINT [ "npm", "start" ]
Loading