-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b4b4ef
commit 9142da3
Showing
36 changed files
with
3,064 additions
and
2,238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* HTTP Status Code Constants | ||
* Defines standard HTTP status codes used throughout the application | ||
*/ | ||
export const HTTP_STATUS = { | ||
// 2xx Success | ||
OK: 200, | ||
CREATED: 201, | ||
ACCEPTED: 202, | ||
NO_CONTENT: 204, | ||
|
||
// 3xx Redirection | ||
MOVED_PERMANENTLY: 301, | ||
FOUND: 302, | ||
NOT_MODIFIED: 304, | ||
TEMPORARY_REDIRECT: 307, | ||
PERMANENT_REDIRECT: 308, | ||
|
||
// 4xx Client Errors | ||
BAD_REQUEST: 400, | ||
UNAUTHORIZED: 401, | ||
FORBIDDEN: 403, | ||
NOT_FOUND: 404, | ||
METHOD_NOT_ALLOWED: 405, | ||
CONFLICT: 409, | ||
GONE: 410, | ||
PRECONDITION_FAILED: 412, | ||
UNPROCESSABLE_ENTITY: 422, | ||
TOO_MANY_REQUESTS: 429, | ||
|
||
// 5xx Server Errors | ||
INTERNAL_SERVER_ERROR: 500, | ||
NOT_IMPLEMENTED: 501, | ||
BAD_GATEWAY: 502, | ||
SERVICE_UNAVAILABLE: 503, | ||
GATEWAY_TIMEOUT: 504 | ||
} as const; | ||
|
||
// Type for HTTP status codes | ||
export type HttpStatus = typeof HTTP_STATUS[keyof typeof HTTP_STATUS]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Centralized Timing Configuration | ||
* Defines all timing-related constants for authentication, caching, and sessions | ||
* @version 1.0.0 | ||
*/ | ||
|
||
export const TIMING_CONFIG = { | ||
/** | ||
* Authentication Token Configuration | ||
*/ | ||
AUTH: { | ||
ACCESS_TOKEN: { | ||
DURATION_MS: 3600000, // 1 hour | ||
DURATION_SEC: 3600, | ||
REFRESH_THRESHOLD_MS: 300000, // Refresh 5 minutes before expiry | ||
EXPIRY: '1h' | ||
}, | ||
REFRESH_TOKEN: { | ||
DURATION_MS: 1209600000, // 14 days | ||
DURATION_SEC: 1209600, | ||
EXPIRY: '14d' | ||
} | ||
}, | ||
|
||
/** | ||
* Session Management Configuration | ||
*/ | ||
SESSION: { | ||
TTL_SEC: 86400, // 24 hours | ||
CHECK_INTERVAL_MS: 300000, // Check every 5 minutes | ||
INACTIVITY_WARNING_MS: 300000, // Show warning after 5 minutes inactivity | ||
VALIDATION_CACHE_TTL_MS: 900000, // 15 minutes | ||
MAX_CONSECUTIVE_FAILURES: 3 | ||
}, | ||
|
||
/** | ||
* Cache Duration Configuration | ||
*/ | ||
CACHE: { | ||
SHORT: { | ||
TTL_SEC: 300, // 5 minutes | ||
TTL_MS: 300000, | ||
DESCRIPTION: 'For frequently changing data (metrics, real-time data)' | ||
}, | ||
MEDIUM: { | ||
TTL_SEC: 900, // 15 minutes | ||
TTL_MS: 900000, | ||
DESCRIPTION: 'For semi-static data (user profiles, company data)' | ||
}, | ||
LONG: { | ||
TTL_SEC: 3600, // 1 hour | ||
TTL_MS: 3600000, | ||
DESCRIPTION: 'For static data (configurations, settings)' | ||
} | ||
}, | ||
|
||
/** | ||
* Rate Limiting Configuration | ||
*/ | ||
RATE_LIMIT: { | ||
WINDOW_MS: 900000, // 15 minutes | ||
MAX_REQUESTS: 100, | ||
DELAY_AFTER_FAILURE_MS: 1000 // 1 second delay after each failure | ||
} | ||
} as const; | ||
|
||
/** | ||
* Type definitions for timing configuration | ||
*/ | ||
export type TimingConfig = typeof TIMING_CONFIG; | ||
export type AuthTiming = typeof TIMING_CONFIG.AUTH; | ||
export type SessionTiming = typeof TIMING_CONFIG.SESSION; | ||
export type CacheTiming = typeof TIMING_CONFIG.CACHE; | ||
export type RateLimitTiming = typeof TIMING_CONFIG.RATE_LIMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,45 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
try { | ||
// Drop existing indexes that might cause conflicts | ||
const dropIndexes = [ | ||
'data_sources_name_idx', | ||
'data_sources_active_idx', | ||
'data_sources_type_idx', | ||
'idx_benchmark_metric_revenue', | ||
'idx_benchmark_report_date', | ||
'idx_benchmark_source', | ||
'metrics_name_idx', | ||
'metrics_category_idx', | ||
'metrics_active_idx', | ||
'users_email_idx', | ||
'users_role_idx', | ||
]; | ||
|
||
for (const indexName of dropIndexes) { | ||
await queryInterface.sequelize | ||
.query( | ||
` | ||
DROP INDEX IF EXISTS ${indexName}; | ||
` | ||
) | ||
.catch(() => { | ||
// Ignore error if index doesn't exist | ||
console.log(`Note: Index ${indexName} might not exist, skipping...`); | ||
}); | ||
} | ||
} catch (error) { | ||
console.error('Migration failed:', error); | ||
throw error; | ||
} | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
// Nothing to do in down migration since this is just cleanup | ||
}, | ||
}; | ||
'use strict'; | ||
|
||
import { QueryInterface } from 'sequelize'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface: QueryInterface) { | ||
try { | ||
// Drop existing indexes that might cause conflicts | ||
const dropIndexes = [ | ||
'data_sources_name_idx', | ||
'data_sources_active_idx', | ||
'data_sources_type_idx', | ||
'idx_benchmark_metric_revenue', | ||
'idx_benchmark_report_date', | ||
'idx_benchmark_source', | ||
'metrics_name_idx', | ||
'metrics_category_idx', | ||
'metrics_active_idx', | ||
'users_email_idx', | ||
'users_role_idx', | ||
]; | ||
|
||
for (const indexName of dropIndexes) { | ||
await queryInterface.sequelize | ||
.query( | ||
` | ||
DROP INDEX IF EXISTS ${indexName}; | ||
` | ||
) | ||
.catch(() => { | ||
// Ignore error if index doesn't exist | ||
console.log(`Note: Index ${indexName} might not exist, skipping...`); | ||
}); | ||
} | ||
} catch (error) { | ||
console.error('Migration failed:', error); | ||
throw error; | ||
} | ||
}, | ||
|
||
async down(queryInterface: QueryInterface) { | ||
// Nothing to do in down migration since this is just cleanup | ||
}, | ||
}; |
Oops, something went wrong.