Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a89c0a7
refactor: improve maintainability of userLinks.js
fraidakis Dec 25, 2025
ddd2cee
refactor: improve maintainability of errorHandler.js
fraidakis Dec 25, 2025
6ba5b7e
refactor: improve maintainability of constants.js
fraidakis Dec 25, 2025
2385bc9
refactor: improve maintainability of users.js
fraidakis Dec 25, 2025
edea037
refactor: improve maintainability of PreferenceProfile.js and interac…
fraidakis Dec 25, 2025
6ca8c60
refactor: improve maintainability of Report, Review, rateLimiter, and…
fraidakis Dec 25, 2025
ad92bbc
refactor: improve maintainability of preference and favourite control…
fraidakis Dec 25, 2025
24d4865
refactor: improve maintainability of dislikedController, database, an…
fraidakis Dec 25, 2025
47ee0ae
refactor: improve maintainability of placeController, Settings, place…
fraidakis Dec 25, 2025
62aae25
refactor: improve maintainability of db, authRoutes, User, and Place
fraidakis Dec 25, 2025
8986160
refactor: improve maintainability of placeWrite, navigationController…
fraidakis Dec 25, 2025
2b7a616
refactor: reduce complexity in userLinks and constants
fraidakis Dec 25, 2025
c75c8ca
refactor: reduce LOC in seedData, models, rateLimiter, and adminLinks
fraidakis Dec 25, 2025
af10d5c
refactor: reduce LOC in preference and favourite controllers
fraidakis Dec 25, 2025
d7157e9
refactor: reduce LOC in preferenceController and database config
fraidakis Dec 25, 2025
2022dce
refactor: reduce LOC in models and db abstraction
fraidakis Dec 25, 2025
3f558a6
refactor: reduce LOC in Place, User models and controllers
fraidakis Dec 25, 2025
234e0b0
refactor: reduce LOC in placeController, Settings, placeLinks
fraidakis Dec 26, 2025
95a2830
refactor: improve maintainability of model files
fraidakis Dec 26, 2025
09651f4
refactor: improve maintainability of controllers files
fraidakis Dec 26, 2025
49fa688
refactor: improve maintainability of controllers files
fraidakis Dec 26, 2025
ff1448d
feat: convert .js seed data to .json format
fraidakis Dec 26, 2025
4e7f1f7
refactor: improve maintainability of userLinks.js and add tests
fraidakis Dec 26, 2025
3b2e856
test: add model function coverage tests (95.48%)
fraidakis Dec 26, 2025
a813854
refactor: convert config files to JSON for improved maintainability i…
fraidakis Dec 26, 2025
82ac52b
refactor: use destructuring export in constants.js
fraidakis Dec 26, 2025
aaaeda7
refactor: extract helper functions in controllers to improve MI
fraidakis Dec 26, 2025
0f814b5
refactor: extract constants in eslint.config and rateLimiter to impro…
fraidakis Dec 26, 2025
42d7a64
refactor: optimize route files structure while preserving docs
fraidakis Dec 26, 2025
f5aa374
Merge branch 'fraidakis' of https://github.com/fraidakis/software-eng…
fraidakis Dec 26, 2025
16bfee4
refactor: resolve violations
fraidakis Dec 26, 2025
d8eaf0f
refactor: reduce parameter count in responseBuilder.error and sendPag…
fraidakis Dec 26, 2025
24714db
refactor: reduce parameter count in response utility functions
fraidakis Dec 26, 2025
c58b9a2
fix: correct validation message grammar in preferenceCreate
fraidakis Dec 26, 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
140 changes: 12 additions & 128 deletions config/constants.js
Original file line number Diff line number Diff line change
@@ -1,133 +1,17 @@
/**
* Application Constants
* Central location for all application-wide constants
* Application Constants - Central configuration values and enumerations
*/
import { createRequire } from 'module';
const require = createRequire(import.meta.url);

// API Version
export const API_VERSION = '1.6.2';
const config = require('./constants.json');

// JWT Configuration
export const JWT_EXPIRES_IN = '7d';
export const {
API_VERSION, JWT_EXPIRES_IN, DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE,
MIN_PASSWORD_LENGTH, MIN_RATING, MAX_RATING, USER_ROLES,
PLACE_CATEGORIES, REPORT_STATUS, TRANSPORTATION_MODES,
DISTANCE_UNITS, DEFAULT_LOCATION, LANGUAGES,
HTTP_STATUS, ERROR_CODES, SUCCESS_MESSAGES
} = config;

// Pagination
export const DEFAULT_PAGE_SIZE = 20;
export const MAX_PAGE_SIZE = 100;

// User Roles
export const USER_ROLES = {
USER: 'user',
ADMIN: 'admin'
};

// Place Categories
export const PLACE_CATEGORIES = {
MUSEUM: 'MUSEUM',
CULTURE: 'CULTURE',
RESTAURANT: 'RESTAURANT',
NIGHTLIFE: 'NIGHTLIFE',
PARK: 'PARK',
BEACH: 'BEACH',
SPORTS: 'SPORTS',
SHOPPING: 'SHOPPING',
ARCHAEOLOGICAL_SITE: 'ARCHEOLOGICAL_SITES',
MUSEUMS_AND_ART: 'MUSEUMS_AND_ART'
};

// Report Status
export const REPORT_STATUS = {
PENDING: 'PENDING',
REVIEWED: 'REVIEWED',
RESOLVED: 'RESOLVED'
};

// Transportation Modes
export const TRANSPORTATION_MODES = {
WALKING: 'walking',
DRIVING: 'driving',
CYCLING: 'cycling',
TRANSIT: 'transit'
};

// Languages
export const LANGUAGES = {
GREEK: 'GREEK',
ENGLISH: 'ENGLISH',
EL: 'el',
EN: 'en'
};

// Rating Range
export const MIN_RATING = 1;
export const MAX_RATING = 5;

// Password Requirements
export const MIN_PASSWORD_LENGTH = 6;

// Distance Units
export const DISTANCE_UNITS = {
KILOMETERS: 'km',
MILES: 'mi'
};

// Default Location (Thessaloniki)
export const DEFAULT_LOCATION = {
latitude: 40.6401,
longitude: 22.9444
};

// HTTP Status Codes
export const HTTP_STATUS = {
OK: 200,
CREATED: 201,
NO_CONTENT: 204,
BAD_REQUEST: 400,
UNAUTHORIZED: 401,
FORBIDDEN: 403,
NOT_FOUND: 404,
CONFLICT: 409,
INTERNAL_SERVER_ERROR: 500
};

// Error Codes
export const ERROR_CODES = {
VALIDATION_ERROR: 'VALIDATION_ERROR',
AUTHENTICATION_ERROR: 'AUTHENTICATION_ERROR',
AUTHORIZATION_ERROR: 'AUTHORIZATION_ERROR',
NOT_FOUND: 'NOT_FOUND',
CONFLICT: 'CONFLICT',
INTERNAL_SERVER_ERROR: 'INTERNAL_SERVER_ERROR',
INVALID_TOKEN: 'INVALID_TOKEN',
TOKEN_EXPIRED: 'TOKEN_EXPIRED',
DUPLICATE_KEY: 'DUPLICATE_KEY'
};

// Success Messages
export const SUCCESS_MESSAGES = {
LOGIN: 'Login successful',
SIGNUP: 'Signup successful',
PROFILE_UPDATED: 'Profile updated successfully',
SETTINGS_UPDATED: 'Settings updated successfully',
CREATED: 'Resource created successfully',
UPDATED: 'Resource updated successfully',
DELETED: 'Resource deleted successfully'
};

export default {
API_VERSION,
JWT_EXPIRES_IN,
DEFAULT_PAGE_SIZE,
MAX_PAGE_SIZE,
USER_ROLES,
PLACE_CATEGORIES,
REPORT_STATUS,
TRANSPORTATION_MODES,
LANGUAGES,
MIN_RATING,
MAX_RATING,
MIN_PASSWORD_LENGTH,
DISTANCE_UNITS,
DEFAULT_LOCATION,
HTTP_STATUS,
ERROR_CODES,
SUCCESS_MESSAGES
};
export default config;
81 changes: 81 additions & 0 deletions config/constants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"API_VERSION": "1.6.2",
"JWT_EXPIRES_IN": "7d",
"DEFAULT_PAGE_SIZE": 20,
"MAX_PAGE_SIZE": 100,
"MIN_PASSWORD_LENGTH": 6,
"MIN_RATING": 1,
"MAX_RATING": 5,
"USER_ROLES": {
"USER": "user",
"ADMIN": "admin"
},
"PLACE_CATEGORIES": {
"MUSEUM": "MUSEUM",
"CULTURE": "CULTURE",
"RESTAURANT": "RESTAURANT",
"NIGHTLIFE": "NIGHTLIFE",
"PARK": "PARK",
"BEACH": "BEACH",
"SPORTS": "SPORTS",
"SHOPPING": "SHOPPING",
"ARCHAEOLOGICAL_SITE": "ARCHEOLOGICAL_SITES",
"MUSEUMS_AND_ART": "MUSEUMS_AND_ART"
},
"REPORT_STATUS": {
"PENDING": "PENDING",
"REVIEWED": "REVIEWED",
"RESOLVED": "RESOLVED"
},
"TRANSPORTATION_MODES": {
"WALKING": "walking",
"DRIVING": "driving",
"CYCLING": "cycling",
"TRANSIT": "transit"
},
"DISTANCE_UNITS": {
"KILOMETERS": "km",
"MILES": "mi"
},
"DEFAULT_LOCATION": {
"latitude": 40.6401,
"longitude": 22.9444
},
"LANGUAGES": {
"GREEK": "GREEK",
"ENGLISH": "ENGLISH",
"EL": "el",
"EN": "en"
},
"HTTP_STATUS": {
"OK": 200,
"CREATED": 201,
"NO_CONTENT": 204,
"BAD_REQUEST": 400,
"UNAUTHORIZED": 401,
"FORBIDDEN": 403,
"NOT_FOUND": 404,
"CONFLICT": 409,
"INTERNAL_SERVER_ERROR": 500
},
"ERROR_CODES": {
"VALIDATION_ERROR": "VALIDATION_ERROR",
"AUTHENTICATION_ERROR": "AUTHENTICATION_ERROR",
"AUTHORIZATION_ERROR": "AUTHORIZATION_ERROR",
"NOT_FOUND": "NOT_FOUND",
"CONFLICT": "CONFLICT",
"INTERNAL_SERVER_ERROR": "INTERNAL_SERVER_ERROR",
"INVALID_TOKEN": "INVALID_TOKEN",
"TOKEN_EXPIRED": "TOKEN_EXPIRED",
"DUPLICATE_KEY": "DUPLICATE_KEY"
},
"SUCCESS_MESSAGES": {
"LOGIN": "Login successful",
"SIGNUP": "Signup successful",
"PROFILE_UPDATED": "Profile updated successfully",
"SETTINGS_UPDATED": "Settings updated successfully",
"CREATED": "Resource created successfully",
"UPDATED": "Resource updated successfully",
"DELETED": "Resource deleted successfully"
}
}
Loading
Loading