Skip to content

Commit a17251a

Browse files
Merge pull request #15 from topcoder-platform/gaoziqiang007-develop
remove resource call to v4 challenge api Gaoziqiang007 develop
2 parents 7f189c5 + f5dd32c commit a17251a

19 files changed

+2735
-44
lines changed

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ if not provided, then SSL connection is not used, direct insecure connection is
5555
- TOKEN_CACHE_TIME: Cache time of M2M token, optional
5656
- AUTH0_CLIENT_ID: Auth0 client id for M2M token
5757
- AUTH0_CLIENT_SECRET: Auth0 client secret for M2M token
58+
- IS_CREATE_FORUM: Should create forum resource or not
59+
- CHALLENGE_ORIGINATOR: originator from challenge service
5860

5961
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
6062

Diff for: challenge-api-v5-mock/mock-challenge-api.js

+15-18
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,36 @@ const http = require('http')
55
const send = require('http-json-response')
66
const _ = require('lodash')
77

8-
98
// Sample challenge
109
const sampleChallenge = {
11-
"id": "96059e8d-4761-4978-9a14-c86ae6b971c3",
12-
"legacyId": 30049360,
13-
"type": "Code",
14-
"track": "Develop",
15-
"name": "Test Challenge 1",
16-
"description": "Test Challenge 1 - Description",
17-
"challengeSettings": [
10+
'id': '96059e8d-4761-4978-9a14-c86ae6b971c3',
11+
'legacyId': 30049360,
12+
'type': 'Code',
13+
'track': 'Develop',
14+
'name': 'Test Challenge 1',
15+
'description': 'Test Challenge 1 - Description',
16+
'challengeSettings': [
1817
{
19-
"type": "setting1",
20-
"value": "value1"
18+
'type': 'setting1',
19+
'value': 'value1'
2120
}
2221
],
23-
"created": "2019-03-02T14:35:53.948Z",
24-
"createdBy": "Copilot1",
25-
"updated": "2019-03-02T14:35:53.948Z",
26-
"updatedBy": "Copilot1"
22+
'created': '2019-03-02T14:35:53.948Z',
23+
'createdBy': 'Copilot1',
24+
'updated': '2019-03-02T14:35:53.948Z',
25+
'updatedBy': 'Copilot1'
2726
}
2827

29-
3028
const responses = {
3129
'/v5/challenges/96059e8d-4761-4978-9a14-c86ae6b971c3': sampleChallenge
3230
}
3331

3432
const mockChallengeV5Api = http.createServer((req, res) => {
35-
36-
if (req.method === 'GET' && _.includes(Object.keys(responses), req.url)) {
33+
if (req.method === 'GET' && _.includes(Object.keys(responses), req.url)) {
3734
return send(res, 200, responses[req.url])
3835
} else {
3936
// 404 for other routes
40-
return send(res, 404, {message : 'Challenge not found'})
37+
return send(res, 404, {message: 'Challenge not found'})
4138
}
4239
})
4340

Diff for: config/default.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,36 @@ module.exports = {
2222

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

25+
IS_CREATE_FORUM: process.env.IS_CREATE_FORUM || true,
26+
2527
CREATE_CHALLENGE_RESOURCE_TOPIC: process.env.CREATE_CHALLENGE_RESOURCE_TOPIC || 'challenge.action.resource.create',
2628
DELETE_CHALLENGE_RESOURCE_TOPIC: process.env.DELETE_CHALLENGE_RESOURCE_TOPIC || 'challenge.action.resource.delete',
2729

30+
CHALLENGE_ORIGINATOR: process.env.CHALLENGE_ORIGINATOR || 'app.challenge.service',
31+
2832
CHALLENGE_API_V4_URL: process.env.CHALLENGE_API_V4_URL || 'https://api.topcoder-dev.com/v4/challenges',
2933
CHALLENGE_API_V5_URL: process.env.CHALLENGE_API_V5_URL || 'http://localhost:3001/v5/challenges',
30-
RESOURCE_ROLE_API_URL: process.env.RESOURCE_ROLE_API_URL || 'https://api.topcoder-dev.com/v5/resource-roles',
3134

3235
AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token', // Auth0 credentials for M2M token
3336
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE || 'https://m2m.topcoder-dev.com/',
3437
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID || 'e6oZAxnoFvjdRtjJs1Jt3tquLnNSTs0e',
3538
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET || 'invalid',
3639
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL || 'https://topcoder-dev.auth0.com/oauth/token',
37-
TOKEN_CACHE_TIME: 90
40+
TOKEN_CACHE_TIME: 90,
41+
42+
INFORMIX: {
43+
SERVER: process.env.INFORMIX_SERVER || 'informixoltp_tcp', // informix server
44+
DATABASE: process.env.INFORMIX_DATABASE || 'tcs_catalog', // informix database
45+
HOST: process.env.INFORMIX_HOST || 'localhost', // host
46+
PROTOCOL: process.env.INFORMIX_PROTOCOL || 'onsoctcp',
47+
PORT: process.env.INFORMIX_PORT || '2021', // port
48+
DB_LOCALE: process.env.INFORMIX_DB_LOCALE || 'en_US.57372',
49+
USER: process.env.INFORMIX_USER || 'informix', // user
50+
PASSWORD: process.env.INFORMIX_PASSWORD || '1nf0rm1x', // password
51+
POOL_MAX_SIZE: parseInt(process.env.INFORMIX_POOL_MAX_SIZE, 10) || 60,
52+
maxsize: parseInt(process.env.MAXSIZE) || 0,
53+
minpool: parseInt(process.env.MINPOOL, 10) || 1,
54+
idleTimeout: parseInt(process.env.IDLETIMEOUT, 10) || 3600,
55+
timeout: parseInt(process.env.TIMEOUT, 10) || 30000
56+
}
3857
}

Diff for: docker/Dockerfile

100755100644
+46-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,49 @@
1-
# Use the base image with Node.js 10.15-jessie
2-
FROM node:10.15-jessie
1+
FROM ibmcom/informix-innovator-c:12.10.FC12W1IE
32

4-
# Copy the current directory into the Docker image
5-
COPY . /legacy-resources-processor
3+
ARG servername=informix
64

7-
# Set working directory for future use
8-
WORKDIR /legacy-resources-processor
5+
USER root
6+
RUN mkdir /app
7+
WORKDIR /home/informix
98

10-
# Install the dependencies from package.json
11-
RUN npm install
12-
CMD npm run start
9+
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
10+
echo "deb http://ftp.debian.org/debian/ stretch main non-free contrib" >/etc/apt/sources.list && \
11+
echo "deb http://security.debian.org/ stretch/updates main contrib non-free" >>/etc/apt/sources.list
12+
13+
RUN apt-get -qq update && \
14+
apt-get -qq install -y wget gcc-6 g++-6 make xz-utils python2.7 git curl
15+
16+
RUN wget -q -O node10.tar.xz https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz \
17+
&& tar xfJ node10.tar.xz && rm -rf node10.tar.xz
18+
19+
ENV SERVERNAME=$servername
20+
21+
COPY docker/esql /opt/ibm/informix/bin/
22+
23+
RUN chmod +x /opt/ibm/informix/bin/esql
24+
RUN echo "informixoltp_tcp onsoctcp $SERVERNAME sqlexec" \
25+
> /opt/ibm/informix/etc/sqlhosts.informixoltp_tcp
26+
27+
ENV INFORMIXDIR /opt/ibm/informix
28+
ENV INFORMIX_HOME /home/informix
29+
ENV INFORMIXSERVER informixoltp_tcp
30+
ENV INFORMIXTERM terminfo
31+
ENV CLIENT_LOCALE=en_US.utf8
32+
ENV DB_LOCALE=en_US.utf8
33+
ENV DBDATE Y4MD-
34+
ENV DBDELIMITER "|"
35+
ENV PATH /home/informix/node-v10.15.1-linux-x64/bin:${INFORMIXDIR}/bin:${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${PATH}
36+
ENV LD_LIBRARY_PATH ${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${INFORMIXDIR}/lib/cli
37+
ENV INFORMIXSQLHOSTS /opt/ibm/informix/etc/sqlhosts.informixoltp_tcp
38+
ENV USER root
39+
ENV LICENSE accept
40+
41+
RUN ln -s /usr/bin/python2.7 /usr/bin/python
42+
RUN echo "sqlexec 2021/tcp" >> /etc/services
43+
44+
COPY . /app
45+
46+
WORKDIR /app
47+
RUN rm -rf node_modules && npm install --unsafe-perm
48+
49+
ENTRYPOINT [ "npm", "start" ]

0 commit comments

Comments
 (0)