-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #1055 (endpoint) to cache on target date(s);
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { json } from '@sveltejs/kit'; | ||
|
||
import { | ||
get_target_hset_cache_data, | ||
get_target_string_cache_data | ||
} from '../../std_main'; | ||
|
||
import { | ||
LS2_C_D_A, | ||
LS2_C_T_A | ||
} from 'betarena-types/redis/config'; | ||
|
||
/** @type {import('@sveltejs/kit').RequestHandler} */ | ||
export async function GET(req): Promise<unknown> { | ||
const lang: string = | ||
req.url['searchParams'].get('lang'); | ||
|
||
// [ℹ] (data) | ||
if (!lang) { | ||
const response = | ||
await get_target_string_cache_data( | ||
LS2_C_D_A | ||
); | ||
if (response) { | ||
return json(response); | ||
} | ||
// [ℹ] otherwise, there is NO MATCHES available; | ||
return json(null); | ||
} | ||
|
||
// [ℹ] (translation - inc. SEO) | ||
if (lang) { | ||
const response_cache = | ||
await get_target_hset_cache_data( | ||
LS2_C_T_A, | ||
lang | ||
); | ||
if (response_cache) { | ||
return json(response_cache); | ||
} | ||
} | ||
|
||
// [ℹ] should never happen; | ||
return json(null); | ||
} |