Skip to content

Dry Release v0.1 #59

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 44 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
10a7c41
validate skills before create/update jobs
imcaizheng Nov 27, 2020
e9fb3d2
Merge pull request #18 from imcaizheng/validate-for-valid-skills
nkumar-topcoder Nov 30, 2020
e3dea78
make sure user exist in both v3 api and v5 api (#19)
imcaizheng Dec 1, 2020
31c82ee
fix weekly count (#20)
imcaizheng Dec 1, 2020
f85cb45
allow normal topcoder members to create jobs and update/delete the jobs
imcaizheng Dec 1, 2020
9fd9e66
Merge pull request #21 from imcaizheng/access-create-jobs-for-all-mem…
nkumar-topcoder Dec 2, 2020
ca0876f
update access rules for /jobs endpoints in Swagger
imcaizheng Dec 2, 2020
d7dc87d
Merge pull request #25 from imcaizheng/access-create-jobs-for-all-mem…
nkumar-topcoder Dec 2, 2020
4a7221f
fix calculation of last week day
imcaizheng Dec 2, 2020
1e50697
add workload field to Job model
imcaizheng Dec 2, 2020
211532d
Merge pull request #28 from imcaizheng/fix-last-week-day-calulation
nkumar-topcoder Dec 3, 2020
6763c7d
Merge pull request #31 from imcaizheng/add-workload-field
nkumar-topcoder Dec 3, 2020
e192960
populate jobIds in resources for GET /taas-teams/:id and populate ski…
imcaizheng Dec 3, 2020
fee5a75
Merge pull request #38 from imcaizheng/more-fields-to-return
maxceem Dec 3, 2020
1517cb1
return skills instead of skillids for GET /taas-teams/:id/jobs/:jobId
imcaizheng Dec 3, 2020
cb5d9ed
Merge pull request #39 from imcaizheng/more-fields-to-return
maxceem Dec 3, 2020
38787dd
allow m2m users to access the API
imcaizheng Dec 4, 2020
ef79f76
GET /taas-teams supports `perPage`, `page`, `sortBy`, `sortOrder`, an…
imcaizheng Dec 4, 2020
bf56071
remove unnecessary code
imcaizheng Dec 4, 2020
a1ad5c0
update status of candidate when the candidate is booked
imcaizheng Dec 4, 2020
be08494
Merge pull request #44 from imcaizheng/improve-search-taas-teams
maxceem Dec 7, 2020
f3328f7
fix: return arrays of records without "result"
maxceem Dec 7, 2020
672e7e6
improve: sort teams by "lastActivityAt" by default
maxceem Dec 7, 2020
73936d7
fix: remove "result" in swagger
maxceem Dec 7, 2020
44a26d2
fix: rename "weeklyCount" to "weeklyCost"
maxceem Dec 8, 2020
857c1b7
Merge pull request #43 from imcaizheng/add-m2m-support
maxceem Dec 8, 2020
061e893
Merge branch 'feature/integration-test-fix' into feature/m2m-support
maxceem Dec 8, 2020
c79d11d
Merge pull request #48 from topcoder-platform/feature/m2m-support
maxceem Dec 8, 2020
bed2699
check if status being changed before updating candidates
imcaizheng Dec 8, 2020
c7069ed
Merge branch 'feature/integration-test-fix' into update-booked-candid…
imcaizheng Dec 8, 2020
b8c503f
Merge pull request #45 from imcaizheng/update-booked-candidate-status
maxceem Dec 8, 2020
74c3b36
tests: postman for creating demo data
maxceem Dec 8, 2020
1998370
fix: load user skills fast for teams
maxceem Dec 9, 2020
91c98df
fix: return skills for job candidates
maxceem Dec 9, 2020
2034ddc
docs: rename demo jobs in postman
maxceem Dec 9, 2020
9b19efa
Merge branch 'dev' into feature/integration-test-fix
maxceem Dec 10, 2020
b4672ca
Merge pull request #52 from topcoder-platform/feature/integration-tes…
maxceem Dec 10, 2020
9318961
chore: deploy only "dev" branch to DEV env
maxceem Dec 10, 2020
df59e38
add input checks of jobId and userId
imcaizheng Dec 14, 2020
799ab70
fix function `_getAssignedResourceBooking()`
imcaizheng Dec 14, 2020
fd9bb61
Merge pull request #55 from imcaizheng/add-input-checks-of-jobId-userId
maxceem Dec 15, 2020
2ff7519
Merge pull request #57 from topcoder-platform/feature/integration-tes…
maxceem Dec 15, 2020
b4e9ed5
Merge pull request #56 from imcaizheng/fix-get-assigned-resource-book…
maxceem Dec 15, 2020
2f30696
docs: improve demo data script
maxceem Dec 15, 2020
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
10 changes: 4 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,28 @@ jobs:
environment:
DEPLOY_ENV: "DEV"
LOGICAL_ENV: "dev"
APPNAME: "taas-apis"
APPNAME: "taas-apis"
steps: *builddeploy_steps

"build-prod":
<<: *defaults
environment:
DEPLOY_ENV: "PROD"
LOGICAL_ENV: "prod"
APPNAME: "taas-apis"
LOGICAL_ENV: "prod"
APPNAME: "taas-apis"
steps: *builddeploy_steps

workflows:
version: 2
build:
jobs:
# Development builds are executed on "develop" branch only.
# Development builds are executed on "develop" branch only.
- "build-dev":
context : org-global
filters:
branches:
only:
- dev
- feature/es-segregation
- feature/integration-test-fix

# Production builds are exectuted only on tagged commits to the
# master branch.
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,7 @@ dist
.pnp.*

# api.env
api.env
api.env

# macOS files
.DS_Store
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ The following parameters can be set in config files or in env variables:
- `AUTH0_CLIENT_SECRET`: Auth0 client secret, used to get TC M2M token
- `AUTH0_PROXY_SERVER_URL`: Proxy Auth0 URL, used to get TC M2M token

- `m2m.M2M_AUDIT_USER_ID`: default value is `00000000-0000-0000-0000-000000000000`
- `m2m.M2M_AUDIT_HANDLE`: default value is `TopcoderService`

- `DATABASE_URL`: PostgreSQL database url.
- `DB_SCHEMA_NAME`: string - PostgreSQL database target schema
- `PROJECT_API_URL`: the project service url
Expand Down
26 changes: 25 additions & 1 deletion app-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ const UserRoles = {
BookingManager: 'bookingmanager'
}

const Scopes = {
// job
READ_JOB: 'read:taas-jobs',
CREATE_JOB: 'create:taas-jobs',
UPDATE_JOB: 'update:taas-jobs',
DELETE_JOB: 'delete:taas-jobs',
ALL_JOB: 'all:taas-jobs',
// job candidate
READ_JOB_CANDIDATE: 'read:taas-jobCandidates',
CREATE_JOB_CANDIDATE: 'create:taas-jobCandidates',
UPDATE_JOB_CANDIDATE: 'update:taas-jobCandidates',
DELETE_JOB_CANDIDATE: 'delete:taas-jobCandidates',
ALL_JOB_CANDIDATE: 'all:taas-jobCandidates',
// resource booking
READ_RESOURCE_BOOKING: 'read:taas-resourceBookings',
CREATE_RESOURCE_BOOKING: 'create:taas-resourceBookings',
UPDATE_RESOURCE_BOOKING: 'update:taas-resourceBookings',
DELETE_RESOURCE_BOOKING: 'delete:taas-resourceBookings',
ALL_RESOURCE_BOOKING: 'all:taas-resourceBookings',
// taas-team
READ_TAAS_TEAM: 'read:taas-teams'
}

module.exports = {
UserRoles
UserRoles,
Scopes
}
20 changes: 16 additions & 4 deletions app-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const _ = require('lodash')
const config = require('config')
const HttpStatus = require('http-status-codes')
const helper = require('./src/common/helper')
const errors = require('./src/common/errors')
const routes = require('./src/routes')
const constants = require('./app-constants')
const authenticator = require('tc-core-library-js').middleware.jwtAuthenticator
Expand Down Expand Up @@ -37,11 +38,22 @@ module.exports = (app) => {
})

actions.push((req, res, next) => {
req.authUser.jwtToken = req.headers.authorization
if (_.includes(req.authUser.roles, constants.UserRoles.BookingManager)) {
req.authUser.isBookingManager = true
if (req.authUser.isMachine) {
// M2M
if (!req.authUser.scopes || !helper.checkIfExists(def.scopes, req.authUser.scopes)) {
next(new errors.ForbiddenError('You are not allowed to perform this action!'))
} else {
req.authUser.userId = config.m2m.M2M_AUDIT_USER_ID
req.authUser.handle = config.m2m.M2M_AUDIT_HANDLE
next()
}
} else {
req.authUser.jwtToken = req.headers.authorization
if (_.includes(req.authUser.roles, constants.UserRoles.BookingManager)) {
req.authUser.isBookingManager = true
}
next()
}
next()
})
}

Expand Down
5 changes: 4 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const logger = require('./src/common/logger')
// setup express app
const app = express()

app.use(cors())
app.use(cors({
// Allow browsers access pagination data in headers
exposedHeaders: ['X-Page', 'X-Per-Page', 'X-Total', 'X-Total-Pages', 'X-Prev-Page', 'X-Next-Page']
}))
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.set('port', config.PORT)
Expand Down
7 changes: 7 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ module.exports = {
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET,
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL,

m2m: {
M2M_AUDIT_USER_ID: process.env.M2M_AUDIT_USER_ID || '00000000-0000-0000-0000-000000000000',
M2M_AUDIT_HANDLE: process.env.M2M_AUDIT_HANDLE || 'TopcoderService'
},

TC_API: process.env.TC_API || 'https://api.topcoder-dev.com/v5',
ORG_ID: process.env.ORG_ID || '36ed815b-3da1-49f1-a043-aaed0a4e81ad',

TOPCODER_USERS_API: process.env.TOPCODER_USERS_API || 'https://api.topcoder-dev.com/v3/users',

DATABASE_URL: process.env.DATABASE_URL || 'postgres://postgres:postgres@localhost:5432/postgres',
DB_SCHEMA_NAME: process.env.DB_SCHEMA_NAME || 'bookings',
PROJECT_API_URL: process.env.PROJECT_API_URL || 'https://api.topcoder-dev.com',
Expand Down
Loading