Skip to content

Commit

Permalink
feat: #1055 (endpoint) to cache on target date(s);
Browse files Browse the repository at this point in the history
  • Loading branch information
migbash committed Feb 27, 2023
1 parent 02654e2 commit ad45fb6
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/routes/api/cache/home/livescores-v2/+server.ts
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);
}

0 comments on commit ad45fb6

Please sign in to comment.