Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a371762
refactor: remove dep Redis configuration and communication files
nevil-mathew Sep 4, 2025
d68a458
feat: add cacheHelper module for Redis and internal caching operations
nevil-mathew Sep 11, 2025
96ca958
feat: integrate caching mechanism for user profile retrieval and updates
nevil-mathew Sep 11, 2025
25c96a0
feat: enhance user read method to include organization code in user d…
nevil-mathew Sep 11, 2025
d7119e5
fix: correct spelling of ENGLISH_LANGUAGE_CODE in common constants an…
nevil-mathew Sep 11, 2025
43b08fb
chore: update elevate-node-cache dependency to version 2.0.0
nevil-mathew Sep 11, 2025
53114ee
feat: implement caching for tenant domain, tenant details and entity …
nevil-mathew Sep 11, 2025
406a70e
feat: implement versioning support in cache helper with TTL managemen…
nevil-mathew Sep 15, 2025
a1eb5d5
feat: enhance entity type management with cache invalidation on creat…
nevil-mathew Sep 15, 2025
072a870
feat: add cache invalidation for entity operations on create, update,…
nevil-mathew Sep 15, 2025
83f3397
feat: implement caching for read operations of system and user entity…
nevil-mathew Sep 15, 2025
6d867ac
feat: add default versioning and new namespaces for branding and orga…
nevil-mathew Sep 15, 2025
e6739a3
feat: update caching mechanism to use versioned keys for user profile…
nevil-mathew Sep 15, 2025
b6b80aa
feat: implement cache clearing for deleted user profiles
nevil-mathew Sep 15, 2025
18465cf
fix: update cache key organization ID reference in account and user s…
nevil-mathew Sep 16, 2025
b1f6002
fix: user id reference in change password
nevil-mathew Sep 16, 2025
e23df97
feat: enhance organization service to enforce tenant code in related …
nevil-mathew Sep 22, 2025
4099fff
feat: update user role service to include organization code and inval…
nevil-mathew Sep 22, 2025
1e45f47
feat: add cache invalidation for organization namespace version in ac…
nevil-mathew Sep 22, 2025
887493f
feat: implement cache invalidation for organization and profile names…
nevil-mathew Sep 22, 2025
f857f40
feat: add cache invalidation for tenant updates in tenant helper
nevil-mathew Sep 22, 2025
112fcbc
feat: add cache invalidation for tenant updates in tenant helper
nevil-mathew Sep 22, 2025
f640ade
feat: add message for related organizations not found in locale file
nevil-mathew Sep 22, 2025
0b57cc1
feat: ensure organization ID is included in cache key for organizatio…
nevil-mathew Sep 22, 2025
04425bd
feat: add optional chaining for organizationAttributes and implement …
nevil-mathew Sep 22, 2025
931c0de
fix: improve user instance handling and correct cache invalidation pa…
nevil-mathew Sep 22, 2025
89eada3
feat: add namespace parameter to invalidateTenantVersion for improved…
nevil-mathew Sep 22, 2025
428ac4c
refactor: replace cache invalidation with eviction by pattern for ent…
nevil-mathew Sep 22, 2025
2c59b2e
fix: update cache invalidation to use organization code instead of us…
nevil-mathew Sep 22, 2025
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
26 changes: 0 additions & 26 deletions src/configs/redis.js

This file was deleted.

15 changes: 14 additions & 1 deletion src/constants/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = {
WRITE_ACCESS: 'w',
READ_ACCESS: 'r',
TYPE_ALL: 'all',
ENGLISH_LANGUGE_CODE: 'en',
ENGLISH_LANGUAGE_CODE: 'en',
ORG_CODE_HEADER: 'organizationcode',
TENANT_CODE_HEADER: 'tenantcode',
DELETE_METHOD: 'DELETE',
Expand All @@ -113,4 +113,17 @@ module.exports = {
SIGNEDUP_STATUS: 'SIGNEDUP',
SEQUELIZE_UNIQUE_CONSTRAINT_ERROR: 'SequelizeUniqueConstraintError',
SEQUELIZE_UNIQUE_CONSTRAINT_ERROR_CODE: 'ER_DUP_ENTRY',
CACHE_CONFIG: {
enableCache: true,
enableTracking: true,
shards: 32,
versionDefault: 0,
namespaces: {
profile: { name: 'profile', enabled: true, defaultTtl: 3600, useInternal: false },
entity_types: { name: 'entity_types', enabled: true, defaultTtl: 86400, useInternal: false },
tenant: { name: 'tenant', enabled: true, defaultTtl: 21600, useInternal: false },
branding: { name: 'branding', enabled: true, defaultTtl: 43200, useInternal: false },
organization: { name: 'organization', enabled: true, defaultTtl: 21600, useInternal: false },
},
},
}
13 changes: 10 additions & 3 deletions src/controllers/v1/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ module.exports = class Organization {
})
}

const updatedOrg = await orgService.update(req.params.id, req.body, req.decodedToken.id)
const updatedOrg = await orgService.update(
req.params.id,
req.body,
req.decodedToken.id,
req.decodedToken.tenant_code
)
return updatedOrg
} catch (error) {
return error
Expand Down Expand Up @@ -188,7 +193,8 @@ module.exports = class Organization {
try {
const result = await orgService.addRelatedOrg(
req.params.id ? req.params.id : '',
req.body.related_orgs ? req.body.related_orgs : []
req.body.related_orgs ? req.body.related_orgs : [],
req.decodedToken.tenant_code
)
return result
} catch (error) {
Expand All @@ -199,7 +205,8 @@ module.exports = class Organization {
try {
const result = await orgService.removeRelatedOrg(
req.params.id ? req.params.id : '',
req.body.related_orgs ? req.body.related_orgs : []
req.body.related_orgs ? req.body.related_orgs : [],
req.decodedToken.tenant_code
)
return result
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/v1/user-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ module.exports = class userRole {
req.params.id,
req.body,
req.decodedToken.organization_id,
req.decodedToken.organization_code,
req.decodedToken.tenant_code
)
return updateRole
Expand All @@ -83,6 +84,7 @@ module.exports = class userRole {
return await roleService.delete(
req.params.id,
req.decodedToken.organization_id,
req.decodedToken.organization_code,
req.decodedToken.tenant_code
)
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/v1/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ module.exports = class User {
req.params.id ? req.params.id : req.decodedToken.id,
req.headers,
req.query.language ? req.query.language : '',
req.decodedToken.tenant_code
req.decodedToken.tenant_code,
req.decodedToken.organization_code
)
return userDetails
} catch (error) {
Expand Down
48 changes: 27 additions & 21 deletions src/database/queries/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,36 @@ exports.update = async (filter, update, options = {}) => {
}
}

exports.appendRelatedOrg = async (relatedOrg, ids, options = {}) => {
exports.appendRelatedOrg = async (relatedOrg, ids, tenantCode, options = {}) => {
try {
const whereClause = {
id: ids,
tenant_code: tenantCode, // enforce tenant
[Op.or]: [
{
[Op.not]: {
related_orgs: {
[Op.contains]: [relatedOrg],
},
},
},
{
related_orgs: {
[Op.is]: null,
},
},
],
}
const result = await Organization.update(
{
related_orgs: sequelize.fn('array_append', sequelize.col('related_orgs'), relatedOrg),
},
{
where: {
id: ids,
[Op.or]: [
{
[Op.not]: {
related_orgs: {
[Op.contains]: [relatedOrg],
},
},
},
{
related_orgs: {
[Op.is]: null,
},
},
],
},
where: whereClause,
...options,
individualHooks: true,
}
)

const [rowsAffected, updatedRows] = result
return options.returning ? { rowsAffected, updatedRows } : rowsAffected
} catch (error) {
Expand All @@ -148,13 +149,17 @@ exports.appendRelatedOrg = async (relatedOrg, ids, options = {}) => {
}
}

exports.removeRelatedOrg = async (removedOrgIds, ids, options = {}) => {
// (removedOrgIds, ids, tenantCode, options = {})
exports.removeRelatedOrg = async (removedOrgIds, ids, tenantCode, options = {}) => {
try {
const result = await Organization.update(
{ related_orgs: sequelize.fn('array_remove', sequelize.col('related_orgs'), removedOrgIds) },
{
related_orgs: sequelize.fn('array_remove', sequelize.col('related_orgs'), removedOrgIds),
},
{
where: {
id: ids,
tenant_code: tenantCode, // enforce same tenant
},
...options,
individualHooks: true,
Expand All @@ -168,6 +173,7 @@ exports.removeRelatedOrg = async (removedOrgIds, ids, options = {}) => {
throw error
}
}

exports.listOrganizations = async (page, limit, search) => {
try {
let filterQuery = {
Expand Down
2 changes: 1 addition & 1 deletion src/database/queries/userOrganization.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ exports.findOne = async (filter, options = {}) => {

exports.findAll = async (filter = {}, options = {}) => {
try {
if (options.organizationAttributes.length > 0) {
if (options?.organizationAttributes?.length > 0) {
options.include = [
{
model: Organization,
Expand Down
Loading