Skip to content

Commit e16de74

Browse files
authored
Merge pull request #10 from topcoder-platform/develop
dev to master
2 parents 43d792c + d1e46cd commit e16de74

File tree

96 files changed

+104218
-930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+104218
-930
lines changed

.circleci/config.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: 2
2+
defaults: &defaults
3+
docker:
4+
- image: cimg/python:3.12.1-browsers
5+
install_dependency: &install_dependency
6+
name: Installation of build and deployment dependencies.
7+
command: |
8+
pip3 install awscli --upgrade
9+
install_deploysuite: &install_deploysuite
10+
name: Installation of install_deploysuite.
11+
command: |
12+
git clone --branch v1.4.19 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
13+
cp ./../buildscript/master_deploy.sh .
14+
cp ./../buildscript/buildenv.sh .
15+
cp ./../buildscript/awsconfiguration.sh .
16+
cp ./../buildscript/psvar-processor.sh .
17+
restore_cache_settings_for_build: &restore_cache_settings_for_build
18+
key: docker-node-modules-v6-{{ checksum "yarn.lock" }}
19+
20+
save_cache_settings: &save_cache_settings
21+
key: docker-node-modules-v6-{{ checksum "yarn.lock" }}
22+
paths:
23+
- node_modules
24+
25+
builddeploy_steps: &builddeploy_steps
26+
- checkout
27+
- setup_remote_docker
28+
- run: *install_dependency
29+
- run: *install_deploysuite
30+
- run: ./build.sh ${APPNAME}
31+
- run:
32+
name: Running MasterScript.
33+
command: |
34+
./awsconfiguration.sh $DEPLOY_ENV
35+
source awsenvconf
36+
./psvar-processor.sh -t appenv -p /config/${APPNAME}/deployvar
37+
source deployvar_env
38+
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -j /config/${APPNAME}/appvar,/config/common/global-appvar -i ${APPNAME} -p FARGATE
39+
40+
41+
jobs:
42+
# Build & Deploy against development backend
43+
"build-dev":
44+
!!merge <<: *defaults
45+
environment:
46+
DEPLOY_ENV: "DEV"
47+
LOGICAL_ENV: "dev"
48+
APPNAME: "member-api-v6"
49+
steps: *builddeploy_steps
50+
51+
"build-prod":
52+
!!merge <<: *defaults
53+
environment:
54+
DEPLOY_ENV: "PROD"
55+
LOGICAL_ENV: "prod"
56+
APPNAME: "member-api-v6"
57+
steps: *builddeploy_steps
58+
59+
workflows:
60+
version: 2
61+
build:
62+
jobs:
63+
# Development builds are executed on "develop" branch only.
64+
- "build-dev":
65+
context: org-global
66+
filters:
67+
branches:
68+
only:
69+
- develop
70+
71+
# Production builds are exectuted only on tagged commits to the
72+
# master branch.
73+
- "build-prod":
74+
context: org-global
75+
filters:
76+
branches:
77+
only:
78+
- master
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: AI PR Reviewer
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
permissions:
9+
pull-requests: write
10+
jobs:
11+
tc-ai-pr-review:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repo
15+
uses: actions/checkout@v3
16+
17+
- name: TC AI PR Reviewer
18+
uses: topcoder-platform/tc-ai-pr-reviewer@master
19+
with:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
21+
LAB45_API_KEY: ${{ secrets.LAB45_API_KEY }}
22+
exclude: '**/*.json, **/*.md, **/*.jpg, **/*.png, **/*.jpeg, **/*.bmp, **/*.webp' # Optional: exclude patterns separated by commas

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# can be used locally to config some env variables and after apply them using `source .env`
2+
.env
3+
### Node ###
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
.DS_Store
9+
.tern-port
10+
*#
11+
12+
dist/
13+
14+
# Runtime data
15+
pids
16+
*.pid
17+
*.seed
18+
AGENTS.md
19+
20+
# Directory for instrumented libs generated by jscoverage/JSCover
21+
lib-cov
22+
23+
# Coverage directory used by tools like istanbul
24+
coverage
25+
26+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27+
.grunt
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules
37+
jspm_packages
38+
39+
# Optional npm cache directory
40+
.npm
41+
42+
43+
.DS_Store
44+
.idea
45+
.vscode/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
21.6

ReadMe.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ docker run -d --name memberdb -p 5432:5432 \
2020
After that, please set db URL environment variables:
2121
```bash
2222
export DATABASE_URL="postgresql://johndoe:mypassword@localhost:5432/memberdb"
23+
export SKILLS_DB_URL="postgresql://johndoe:mypassword@localhost:5432/skillsdb"
2324
```
2425

25-
This variable is important since it's required by prisma.
26+
These variables are important since they're required by Prisma clients.
2627

27-
If you want to do anything with database, this variable is necessary.
28+
If you want to do anything with database, these variables are necessary.
2829

2930
## Database Scripts
3031

@@ -33,6 +34,7 @@ Before running db scripts, please make sure you have setup db and config db url
3334
```bash
3435
# set db url values
3536
export DATABASE_URL="postgresql://johndoe:mypassword@localhost:5432/memberdb"
37+
export SKILLS_DB_URL="postgresql://johndoe:mypassword@localhost:5432/skillsdb"
3638

3739
# install dependencies
3840
npm install
@@ -61,7 +63,7 @@ I have created a script to download data from dev environment and a script to lo
6163
To use them, you should:
6264
- Make sure you have started db.
6365
- Check configs in `src/scripts/config.js`. Add some handle if you like.
64-
- Open a terminal and navigate to codebase folder. Set `DATABASE_URL` above.
66+
- Open a terminal and navigate to codebase folder. Set `DATABASE_URL` and `SKILLS_DB_URL` above.
6567
- Run `npm install`.
6668
- Use `node src/scripts/download.js` to download profile data.
6769
- Run `npm run clear-db` to clear db data first
@@ -86,7 +88,7 @@ The following parameters can be set in config files or in env variables:
8688
- BUSAPI_URL: Bus API URL
8789
- KAFKA_ERROR_TOPIC: Kafka error topic used by bus API wrapper
8890
- GROUPS_API_URL: Groups API URL
89-
- AMAZON.AWS_ACCESS_KEY_ID: The Amazon certificate key to use when connecting.
91+
- AMAZON.AWS_ACCESS_KEY_ID: The Amazon certificate key to use when connecting.
9092
- AMAZON.AWS_SECRET_ACCESS_KEY: The Amazon certificate access key to use when connecting.
9193
- AMAZON.AWS.SESSION_TOKEN: The user session token, used when developing locally against the TC dev AWS services
9294
- AMAZON.AWS_REGION: The Amazon certificate region to use when connecting.
@@ -138,6 +140,8 @@ To make local development easier, I create a mock server at `mock`.
138140

139141
You can start it with `node mock/mock-api.js` and it will listen to port `4000`
140142

143+
This mock service will simulate request and responses for other APIs like auth0 and event bus API.
144+
141145
## Local Configs
142146

143147
Please run following commands to set necessary configs:
@@ -147,13 +151,11 @@ export AUTH0_URL="http://localhost:4000/v5/auth0"
147151
export BUSAPI_URL="http://localhost:4000/v5"
148152
export AUTH0_CLIENT_ID=xyz
149153
export AUTH0_CLIENT_SECRET=xyz
150-
export LOOKER_API_BASE_URL="http://localhost:4000/v5/looker"
151-
export LOOKER_API_CLIENT_ID=xyz
152-
export LOOKER_API_CLIENT_SECRET=xyz
153154
export USERFLOW_PRIVATE_KEY=mysecret
155+
export GROUPS_API_URL="http://localhost:4000/v5/groups"
154156
```
155157

156-
These commands will set auth0, event bus pi and looker api to local mock server.
158+
These commands will set auth0 and event bus api to local mock server.
157159

158160
## Local Deployment
159161

@@ -167,12 +169,11 @@ These commands will set auth0, event bus pi and looker api to local mock server.
167169
## Tests
168170

169171

170-
Make sure you have followed above steps to
172+
Make sure you have followed above steps to
171173
- setup db and config db url
172174
- setup local mock api and set local configs
173175
- it will really call service and mock api
174176

175-
Unit tests use `aws-sdk-mock` to mock S3 operations. So you can safely run tests without S3 configs.
176177

177178
Then you can run:
178179
```bash

Verification.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Just be careful about the schemas used for different kind of trait.
5454
There are some changes to prisma schema.
5555

5656
- Add memberTraits.hobby
57+
- Update memberSkill.displayMode to optional
5758
- Remove displayMode.memberSkills @ignore
5859
- Add stats fields as discussed in forum
5960

app-bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Joi.page = () => Joi.number().integer().min(1).default(1)
88
Joi.perPage = () => Joi.number().integer().min(1).max(100).default(50)
99
Joi.size = () => Joi.number().integer().min(1).max(1000).default(500)
1010
Joi.sort = () => Joi.string().default('asc')
11+
Joi.positive = () => Joi.number().integer().min(0)

app-constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* App constants
33
*/
44
const ADMIN_ROLES = ['administrator', 'admin']
5-
const SEARCH_BY_EMAIL_ROLES = ADMIN_ROLES.concat('tgadmin');
5+
const SEARCH_BY_EMAIL_ROLES = ADMIN_ROLES.concat('tgadmin')
66
const AUTOCOMPLETE_ROLES = ['copilot', 'administrator', 'admin', 'Connect Copilot', 'Connect Account Manager', 'Connect Admin', 'Account Executive']
77

88
const EVENT_ORIGINATOR = 'topcoder-member-api'

app.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const HttpStatus = require('http-status-codes')
1313
const logger = require('./src/common/logger')
1414
const interceptor = require('express-interceptor')
1515
const fileUpload = require('express-fileupload')
16+
const path = require('path')
17+
const swaggerUi = require('swagger-ui-express')
18+
const YAML = require('yamljs')
1619

1720
// setup express app
1821
const app = express()
@@ -35,6 +38,18 @@ app.use(bodyParser.json())
3538
app.use(bodyParser.urlencoded({ extended: true }))
3639
app.set('port', config.PORT)
3740

41+
// Swagger / OpenAPI documentation
42+
const swaggerDocument = YAML.load(path.join(__dirname, 'docs', 'swagger.yaml'))
43+
swaggerDocument.basePath = `/${config.API_VERSION}`
44+
const docsRoute = `/${config.API_VERSION}/members/api-docs`
45+
app.use(docsRoute, swaggerUi.serve, swaggerUi.setup(swaggerDocument, {
46+
swaggerOptions: { docExpansion: 'list' },
47+
customSiteTitle: 'Topcoder Member API v6 Documentation'
48+
}))
49+
app.get(`${docsRoute}.json`, (req, res) => {
50+
res.json(swaggerDocument)
51+
})
52+
3853
// intercept the response body from jwtAuthenticator
3954
app.use(interceptor((req, res) => {
4055
return {

build.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
APP_NAME=$1
4+
UPDATE_CACHE=""
5+
#docker-compose -f docker/docker-compose.yml build $APP_NAME
6+
docker build -f docker/Dockerfile -t $APP_NAME:latest .
7+
docker create --name app $APP_NAME:latest
8+
9+
if [ -d node_modules ]
10+
then
11+
mv package-lock.json old-package-lock.json
12+
docker cp app:/$APP_NAME/package-lock.json package-lock.json
13+
set +eo pipefail
14+
UPDATE_CACHE=$(cmp package-lock.json old-package-lock.json)
15+
set -eo pipefail
16+
else
17+
UPDATE_CACHE=1
18+
fi
19+
20+
if [ "$UPDATE_CACHE" == 1 ]
21+
then
22+
docker cp app:/$APP_NAME/node_modules .
23+
fi

0 commit comments

Comments
 (0)