Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

TSJR-12 prepare skills API for action -> dev #30

Merged
merged 8 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add eslint - standard set
  • Loading branch information
kkartunov committed Aug 31, 2023
commit 6d14055be90e5d2434f2b4255ac9b6b27ae9418f
26 changes: 26 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true
},
extends: 'standard',
overrides: [
{
env: {
node: true
},
files: [
'.eslintrc.{js,cjs}'
],
parserOptions: {
sourceType: 'script'
}
}
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
}
}
5 changes: 3 additions & 2 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = {
PORT: process.env.PORT || 3001,

AUTH_SECRET: process.env.AUTH_SECRET || 'CLIENT_SECRET',
VALID_ISSUERS: process.env.VALID_ISSUERS ? process.env.VALID_ISSUERS.replace(/\\"/g, '')
VALID_ISSUERS: process.env.VALID_ISSUERS
? process.env.VALID_ISSUERS.replace(/\\"/g, '')
: '["https://topcoder-dev.auth0.com/", "https://api.topcoder.com"]',

PAGE_SIZE: process.env.PAGE_SIZE || 20,
Expand Down Expand Up @@ -38,7 +39,7 @@ module.exports = {
ES: {
HOST: process.env.ES_HOST || 'http://localhost:9200',
ES_REFRESH: process.env.ES_REFRESH || 'true',
ES_API_VERSION: process.env.ES_API_VERSION || "7.4",
ES_API_VERSION: process.env.ES_API_VERSION || '7.4',

ELASTICCLOUD: {
id: process.env.ELASTICCLOUD_ID,
Expand Down
102 changes: 92 additions & 10 deletions package-lock.json

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

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
"@elastic/elasticsearch": "^8.9.0",
"@hapi/joi": "^16.1.8",
"@topcoder-platform/topcoder-bus-api-wrapper": "github:topcoder-platform/tc-bus-api-wrapper",
"aws-sdk": "^2.1448.0",
"body-parser": "^1.20.2",
"cls-hooked": "^4.2.2",
"config": "^3.3.9",
"cors": "^2.8.5",
"elasticsearch": "^15.0.0",
"express": "^4.18.2",
"get-parameter-names": "^0.3.0",
"handlebars": "^4.7.8",
"http-aws-es": "^6.0.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"pgtools": "^1.0.1",
Expand All @@ -41,12 +44,14 @@
"swagger-ui-express": "^5.0.0",
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.8",
"umzug": "^3.3.1",
"aws-sdk": "^2.1448.0",
"http-aws-es": "^6.0.0",
"elasticsearch": "^15.0.0",
"winston": "^3.10.0"
},
"devDependencies": {
"eslint": "^8.48.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.0.2",
"eslint-plugin-promise": "^6.1.1",
"nodemon": "^3.0.1",
"standard": "^17.1.0"
},
Expand Down
6 changes: 2 additions & 4 deletions scripts/db/migrations/04_create-tcskill.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { DataTypes } = require('sequelize')

module.exports = {
up: async ({ context: queryInterface }) => {

await queryInterface.createTable('TCSkills', {
id: {
primaryKey: true,
Expand All @@ -26,10 +25,9 @@ module.exports = {
})

await queryInterface.addIndex('TCSkills', ['name'], {
name: "TCSkill_name_key",
unique: true,
name: 'TCSkill_name_key',
unique: true
})

},
down: async ({ context: queryInterface }) => {
await queryInterface.dropTable('TCSkills')
Expand Down
4 changes: 2 additions & 2 deletions src/common/es-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function getESClient () {
esClient = new elasticsearch.Client({
apiVersion: config.get('ES.ES_API_VERSION'),
node: host,
connectionClass: require('http-aws-es'), // eslint-disable-line global-require
});
connectionClass: require('http-aws-es') // eslint-disable-line global-require
})
console.log('esClient=> ', esClient)
} else {
esClient = new elasticsearch.Client({
Expand Down
28 changes: 15 additions & 13 deletions src/common/es-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,20 @@ async function updateESRecord (esResourceName, data) {
type: resourceConfig.type,
refresh: config.get('ES.ES_REFRESH'),
id: data.id,
body: data.metadata ? {
script: {
lang: 'painless',
source: 'ctx._source = params.data; ctx._source.metadata = params.metadata',
params: {
data: _.omit(data, ['metadata']),
metadata: data.metadata
body: data.metadata
? {
script: {
lang: 'painless',
source: 'ctx._source = params.data; ctx._source.metadata = params.metadata',
params: {
data: _.omit(data, ['metadata']),
metadata: data.metadata
}
}
}
: {
doc: data
}
}
} : {
doc: data
}
})
}

Expand All @@ -103,7 +105,7 @@ async function deleteESRecord (esResourceName, id) {
index: resourceConfig.index,
type: resourceConfig.type,
refresh: config.get('ES.ES_REFRESH'),
id: id
id
})
}

Expand All @@ -123,7 +125,7 @@ async function getFromElasticSearch (resource, ...args) {
const esQuery = {
index: doc.index,
type: doc.type,
id: id
id
}

logger.debug(`ES query for get ${resource}: ${JSON.stringify(esQuery, null, 2)}`)
Expand Down
2 changes: 1 addition & 1 deletion src/common/script-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function createIndex (index, logger) {
await esClient.indices.create({ index })
await esClient.indices.close({ index })
await esClient.indices.putSettings({
index: index,
index,
body: {
settings: {
analysis: {
Expand Down
6 changes: 3 additions & 3 deletions src/models/TCSkill.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ module.exports = (sequelize) => {
timestamps: true,
indexes: [
{
name: "TCSkill_name_key",
name: 'TCSkill_name_key',
unique: true,
fields: [
{ name: "name" },
{ name: 'name' }
]
},
}
]
})
return TCSkill
Expand Down
11 changes: 6 additions & 5 deletions src/permissions/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ const {
/**
* M2M scopes to "write" projects
*/
const SCOPES_PROJECTS_WRITE = [
M2M_SCOPES.CONNECT_PROJECT_ADMIN,
M2M_SCOPES.PROJECTS.ALL,
M2M_SCOPES.PROJECTS.WRITE
]
// Commented out because it appears to be unused
// const SCOPES_PROJECTS_WRITE = [
// M2M_SCOPES.CONNECT_PROJECT_ADMIN,
// M2M_SCOPES.PROJECTS.ALL,
// M2M_SCOPES.PROJECTS.WRITE
// ]

/**
* The full list of possible permission rules
Expand Down