Consolidate server utilities into shared module
- Add lib/server/utils/normalize.ts with normalizeTicker, normalizeTagsOrNull, nowIso, todayIso - Add lib/server/utils/validation.ts with asRecord, asBoolean, asStringArray, asEnum - Add lib/server/utils/index.ts re-exporting all utilities - Remove duplicate lib/server/utils.ts (old file) - Update all repos and files to use shared utilities - Remove redundant ?? '' from normalizeTicker calls - Update watchlist.ts to use normalizeTagsOrNull for null-return tags
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { CompanyProfile, CompanyValuationSnapshot } from '@/lib/types';
|
||||
import { normalizeTicker } from '@/lib/server/utils';
|
||||
|
||||
type FetchImpl = typeof fetch;
|
||||
|
||||
@@ -261,7 +262,7 @@ export async function getSecCompanyProfile(
|
||||
ticker: string,
|
||||
options?: { fetchImpl?: FetchImpl }
|
||||
): Promise<SecCompanyProfileResult | null> {
|
||||
const normalizedTicker = ticker.trim().toUpperCase();
|
||||
const normalizedTicker = normalizeTicker(ticker);
|
||||
if (!normalizedTicker) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user