Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
55d5d77
v1.6.29 ~ fix company resolution within sms verification code
roncodes Dec 8, 2025
980e05c
can now pass `company_uuid` as an option to verification code generation
roncodes Dec 8, 2025
086ff92
feat: Performance optimizations for queryWithRequest flow
roncodes Dec 16, 2025
b941999
refactor: Complete rewrite of QueryOptimizer for robustness and relia…
roncodes Dec 16, 2025
8856923
fix: Add Eloquent Builder to QueryOptimizer type hints
roncodes Dec 16, 2025
eeb9e08
perf: Optimize Filter base class and fix applyCustomFilters execution
roncodes Dec 16, 2025
f2c6732
fix: Restore original filter behavior for operator-based filters
roncodes Dec 16, 2025
2f622c1
fix: Add searchableFields check for basic filters
roncodes Dec 16, 2025
2036700
fix: Apply searchableFields check to ALL filters (including operator-…
roncodes Dec 16, 2025
19f7228
refactor: Clean up applyOptimizedFilters method
roncodes Dec 16, 2025
7074dc1
fix: CRITICAL - Pass correct operator key to applyOperators
roncodes Dec 16, 2025
d4ec0f9
fix: CRITICAL SECURITY - Ensure custom filters run before fast path
roncodes Dec 16, 2025
d55cd2e
feat: Add configurable throttling with global toggle and unlimited AP…
roncodes Dec 16, 2025
0188ce8
feat: Implement comprehensive API model caching strategy
roncodes Dec 16, 2025
292619e
feat: Make API caching automatic and enabled by default
roncodes Dec 16, 2025
4fec017
feat: Add cache status response headers for easy verification
roncodes Dec 16, 2025
7be3c81
fix: Use Fleetbase Http helper methods in AttachCacheHeaders
roncodes Dec 16, 2025
3061b50
fix: Merge api.php config in CoreServiceProvider
roncodes Dec 16, 2025
d122ef6
fix: Move cache invalidation to HasApiModelBehavior for automatic inv…
roncodes Dec 16, 2025
bdb8da0
fix: Improve cache invalidation with better logging and correct default
roncodes Dec 16, 2025
c4a10f3
fix: Use aggressive Redis key deletion for cache invalidation
roncodes Dec 16, 2025
5531058
fix: Improve Redis key pattern matching with comprehensive logging
roncodes Dec 16, 2025
29997d8
fix: Delete cache keys BEFORE tag flush to prevent race condition
roncodes Dec 16, 2025
fde6357
fix: Add verification to Redis key deletion
roncodes Dec 16, 2025
0d2cfce
fix: Use raw Redis client to bypass Laravel prefix handling
roncodes Dec 16, 2025
424438d
fix: Ensure Redis client uses correct database number
roncodes Dec 16, 2025
71a1289
fix: Complete Redis Cluster cache fix per architectural review
roncodes Dec 16, 2025
5c7a015
fix: Add query-level cache tags to fix invalidation
roncodes Dec 16, 2025
6c2e325
fix: Prevent request-level cache reuse after invalidation
roncodes Dec 16, 2025
67363b3
fix: Properly set cache status for headers (HIT/MISS instead of BYPASS)
roncodes Dec 16, 2025
4720e50
hotfix: remove duplicate `resetCacheStatus` method
roncodes Dec 16, 2025
54020ea
fix: Implement query cache versioning - THE DEFINITIVE FIX
roncodes Dec 16, 2025
19f033e
fix: PolymorphicType cast reverse resolution for namespaced models
roncodes Dec 16, 2025
bc17acb
hotfix: revert polymorphic type cast logic
roncodes Dec 16, 2025
188e048
Revert "fix: PolymorphicType cast reverse resolution for namespaced m…
roncodes Dec 16, 2025
a1f0789
fix: Update toEmberResourceType to output namespaced short types (e.g…
roncodes Dec 16, 2025
1466425
debug: Add logging to ThrottleRequests middleware to trace execution
roncodes Dec 16, 2025
e8829b8
Remove debug logging from ThrottleRequests middleware
roncodes Dec 16, 2025
58b1afd
cleanup comments on throttle middleware
roncodes Dec 16, 2025
1c6f855
Merge pull request #179 from fleetbase/feature/performance-optimizations
roncodes Dec 16, 2025
af8243a
fix: Replace closure serialization with spl_object_id in HasApiModelC…
roncodes Dec 16, 2025
855166e
Merge branch 'feature/performance-optimizations' of github.com:fleetb…
roncodes Dec 16, 2025
7bac70f
Merge pull request #180 from fleetbase/feature/performance-optimizations
roncodes Dec 16, 2025
bf4e26c
improving database connection options
roncodes Dec 17, 2025
0995efc
Merge branch 'dev-v1.6.29' of github.com:fleetbase/core-api into dev-…
roncodes Dec 17, 2025
483803c
feat: Add cache locking to prevent cache stampede in ApiModelCache
roncodes Dec 17, 2025
5240430
ran linter, removed cache logging
roncodes Dec 17, 2025
2570097
Merge branch 'dev-v1.6.29' of github.com:fleetbase/core-api into dev-…
roncodes Dec 17, 2025
8028be7
Fix: Prevent public_id race condition under high load
roncodes Dec 17, 2025
708ae4d
Fix: Increase public_id hash length to 10 chars and improve entropy f…
roncodes Dec 17, 2025
c5f1aa9
Fix: Update isPublicId to support variable-length hashes (7-15 chars)
roncodes Dec 17, 2025
a236e83
Fix: Use random_int() instead of rand() for cryptographically secure …
roncodes Dec 17, 2025
7188135
Fix: Ensure cacheQueryResult never returns null/false
roncodes Dec 17, 2025
81b53d2
Fix: Properly set cache HIT status in fallback path when lock cannot …
roncodes Dec 18, 2025
90afc84
Fix: Use lock->block() instead of lock->get() to properly wait for ca…
roncodes Dec 18, 2025
1efe191
Fix: Correct cache key assignment on line 192
roncodes Dec 18, 2025
4da511a
add $cacheKey to use
roncodes Dec 18, 2025
f86fa1c
Fix: Complete ApiModelCache lock cleanup and HIT/MISS accounting patch
roncodes Dec 18, 2025
657f1c0
Fix: Prevent false HIT reporting and add cache status to exception ha…
roncodes Dec 18, 2025
20c66f2
Fix: Remove spl_object_id() from cache key generation to enable cache…
roncodes Dec 18, 2025
757b257
feat: add indexResource support for lightweight collection responses
roncodes Dec 18, 2025
444ad44
Add image resizing feature with Intervention Image
roncodes Dec 19, 2025
854f23f
Fix ImageService dependency injection issue
roncodes Dec 19, 2025
e844c18
Fix ImageService dependency injection properly with parent::__constru…
roncodes Dec 19, 2025
8764ed3
Fix quality parameter usage in ImageService
roncodes Dec 19, 2025
c410f63
Fix image format detection using file extension
roncodes Dec 19, 2025
35693aa
Added caching trait to logging models
roncodes Dec 19, 2025
059c2bc
Added the image config to the core service provider
roncodes Dec 19, 2025
932e248
Add custom caching for /users/current endpoint
roncodes Dec 19, 2025
3c69489
fix: resolve user cache errors - ambiguous column and undefined relat…
roncodes Dec 19, 2025
a9997d8
fix: remove unnecessary company relationship loading in user current …
roncodes Dec 19, 2025
c9ab2bc
fix: refresh user model to ensure accurate ETag generation
roncodes Dec 19, 2025
744f0da
fix: handle nginx compression suffix in ETag comparison
roncodes Dec 19, 2025
8a2542d
fix: change Cache-Control from max-age to no-cache for proper ETag va…
roncodes Dec 19, 2025
7a3bfc8
Few tweaks
roncodes Dec 19, 2025
7301a52
fix: invalidate organizations cache when user updates
roncodes Dec 19, 2025
60ac58c
refactor: remove weak ETag implementation, use strong ETags
roncodes Dec 19, 2025
8b58ea2
refactor: remove redundant manual If-None-Match check
roncodes Dec 19, 2025
c8ddc7f
fix: use timestamps in organizations ETag generation for stable compa…
roncodes Dec 19, 2025
d029826
feat: add ETag validation middleware for automatic 304 responses
roncodes Dec 19, 2025
de35d48
removed user cache md
roncodes Dec 19, 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
127 changes: 0 additions & 127 deletions SCHEDULING_MODULE.md

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/core-api",
"version": "1.6.28",
"version": "1.6.29",
"description": "Core Framework and Resources for Fleetbase API",
"keywords": [
"fleetbase",
Expand Down Expand Up @@ -36,6 +36,7 @@
"illuminate/support": "^9.0|^10.0",
"inkrot/php-compress-json": "^0.1.1",
"innoge/laravel-msgraph-mail": "^1.4",
"intervention/image": "^3.11",
"jdorn/sql-formatter": "^1.2",
"laravel-notification-channels/apn": "^5.0",
"laravel-notification-channels/fcm": "^4.1",
Expand Down
59 changes: 59 additions & 0 deletions config/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,66 @@

return [
'throttle' => [
// Option 1: Global enable/disable toggle
// Set to false to disable throttling completely (useful for performance testing)
// Default: true (enabled)
// Example: THROTTLE_ENABLED=false
'enabled' => env('THROTTLE_ENABLED', true),

// Maximum number of requests allowed per decay period
// Default: 120 requests per minute
// Example: THROTTLE_REQUESTS_PER_MINUTE=120
'max_attempts' => env('THROTTLE_REQUESTS_PER_MINUTE', 120),

// Time window in minutes for throttle decay
// Default: 1 minute
// Example: THROTTLE_DECAY_MINUTES=1
'decay_minutes' => env('THROTTLE_DECAY_MINUTES', 1),

// Option 3: Unlimited API keys (for production testing)
// Comma-separated list of API keys that bypass throttling
// These keys can be used for performance testing in production
// Example: THROTTLE_UNLIMITED_API_KEYS=Bearer test_key_123,Bearer load_test_456
'unlimited_keys' => array_filter(explode(',', env('THROTTLE_UNLIMITED_API_KEYS', ''))),
],

'cache' => [
// Enable/disable API model caching
// Caching is enabled by default when HasApiModelCache trait is used
// Set to false to disable caching globally
// Default: true (enabled)
// Example: API_CACHE_ENABLED=false
'enabled' => env('API_CACHE_ENABLED', true),

// Cache TTL (Time To Live) in seconds
'ttl' => [
// Query result caching (list endpoints)
// Default: 300 seconds (5 minutes)
// Example: API_CACHE_QUERY_TTL=300
'query' => env('API_CACHE_QUERY_TTL', 300),

// Model instance caching (single record endpoints)
// Default: 3600 seconds (1 hour)
// Example: API_CACHE_MODEL_TTL=3600
'model' => env('API_CACHE_MODEL_TTL', 3600),

// Relationship caching
// Default: 1800 seconds (30 minutes)
// Example: API_CACHE_RELATIONSHIP_TTL=1800
'relationship' => env('API_CACHE_RELATIONSHIP_TTL', 1800),
],

// Cache driver (uses Laravel's cache configuration)
// Options: redis, memcached, database, file
// Default: uses config('cache.default')
'driver' => env('API_CACHE_DRIVER', config('cache.default')),

// Cache key prefix
// Default: 'fleetbase_api'
'prefix' => env('API_CACHE_PREFIX', 'fleetbase_api'),

// Debug mode - adds X-Cache-Key header to responses
// Default: false (only enabled when APP_DEBUG=true)
'debug' => env('API_CACHE_DEBUG', false),
],
];
8 changes: 7 additions & 1 deletion config/database.connections.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
$database = substr($url['path'], 1);
}

$mysql_options = [];
$mysql_options = [
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_TIMEOUT => 5,
];

if (env('APP_ENV') === 'local') {
$mysql_options[PDO::ATTR_EMULATE_PREPARES] = true;
Expand Down Expand Up @@ -68,6 +71,9 @@
'strict' => true,
'engine' => null,
'options' => $mysql_options,
'pool' => [
'size' => env('DB_CONNECTION_POOL_SIZE', 25),
],
],

'sandbox' => [
Expand Down
7 changes: 6 additions & 1 deletion config/fleetbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@
'icon_url' => 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/static/fleetbase-icon.png'
],
'version' => env('FLEETBASE_VERSION', '0.7.1'),
'instance_id' => env('FLEETBASE_INSTANCE_ID') ?? (file_exists(base_path('.fleetbase-id')) ? trim(file_get_contents(base_path('.fleetbase-id'))) : null)
'instance_id' => env('FLEETBASE_INSTANCE_ID') ?? (file_exists(base_path('.fleetbase-id')) ? trim(file_get_contents(base_path('.fleetbase-id'))) : null),
'user_cache' => [
'enabled' => env('USER_CACHE_ENABLED', true),
'server_ttl' => (int) env('USER_CACHE_SERVER_TTL', 900), // 15 minutes
'browser_ttl' => (int) env('USER_CACHE_BROWSER_TTL', 300), // 5 minutes
]
];
145 changes: 145 additions & 0 deletions config/image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Image Processing Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports "GD Library" and "Imagick" to process images
| internally. Depending on your PHP setup, you can choose one of them.
|
| Supported: "gd", "imagick"
|
| Note: The driver is auto-detected based on available extensions.
| Imagick is preferred if available (better quality and more features).
|
*/

'driver' => env('IMAGE_DRIVER', extension_loaded('imagick') ? 'imagick' : 'gd'),

/*
|--------------------------------------------------------------------------
| Default Quality
|--------------------------------------------------------------------------
|
| The default quality for image compression (1-100).
| Higher values mean better quality but larger file sizes.
|
| Recommended: 85 (good balance between quality and size)
|
*/

'default_quality' => env('IMAGE_DEFAULT_QUALITY', 85),

/*
|--------------------------------------------------------------------------
| Allow Upscaling
|--------------------------------------------------------------------------
|
| Whether to allow upscaling small images to larger dimensions.
| When false, images smaller than the target size are left unchanged.
|
| Recommended: false (prevents quality loss from upscaling)
|
*/

'allow_upscale' => env('IMAGE_ALLOW_UPSCALE', false),

/*
|--------------------------------------------------------------------------
| Maximum Dimensions
|--------------------------------------------------------------------------
|
| Safety limits for image dimensions to prevent memory exhaustion.
|
*/

'max_width' => env('IMAGE_MAX_WIDTH', 10000),
'max_height' => env('IMAGE_MAX_HEIGHT', 10000),

/*
|--------------------------------------------------------------------------
| Resize Presets
|--------------------------------------------------------------------------
|
| Predefined dimension presets for common use cases.
| These act as maximum dimensions (images won't be upscaled by default).
|
| Usage: resize=thumb, resize=sm, resize=md, etc.
|
*/

'presets' => [
'thumb' => [
'width' => 150,
'height' => 150,
'name' => 'Thumbnail',
],
'sm' => [
'width' => 320,
'height' => 240,
'name' => 'Small',
],
'md' => [
'width' => 640,
'height' => 480,
'name' => 'Medium',
],
'lg' => [
'width' => 1024,
'height' => 768,
'name' => 'Large',
],
'xl' => [
'width' => 1920,
'height' => 1080,
'name' => 'Extra Large',
],
'2xl' => [
'width' => 2560,
'height' => 1440,
'name' => '2K',
],
],

/*
|--------------------------------------------------------------------------
| Supported Formats
|--------------------------------------------------------------------------
|
| Image formats that can be used for conversion.
|
*/

'formats' => [
'jpg',
'jpeg',
'png',
'webp',
'gif',
'bmp',
'avif',
],

/*
|--------------------------------------------------------------------------
| Resize Modes
|--------------------------------------------------------------------------
|
| Available resize modes:
|
| - fit: Resize to fit within dimensions, maintain aspect ratio (default)
| - crop: Crop to exact dimensions, maintain aspect ratio
| - stretch: Stretch to exact dimensions, ignore aspect ratio
| - contain: Fit within dimensions with padding
|
*/

'modes' => [
'fit',
'crop',
'stretch',
'contain',
],
];
1 change: 0 additions & 1 deletion src/Casts/PolymorphicType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function set($model, $key, $value, $attributes)
{
// default $className is null
$className = null;

if ($value) {
$className = Utils::getMutationType($value);
}
Expand Down
Loading