feat: implement internationalization for UI text, refactor localStorage keys, and add input validation for state setters.
This commit is contained in:
15
src/api.js
15
src/api.js
@@ -1,5 +1,15 @@
|
||||
/**
|
||||
* API header factories for the Bessa REST API and GitHub API.
|
||||
* All fetch calls in the app route through these helpers to ensure
|
||||
* consistent auth and versioning headers.
|
||||
*/
|
||||
import { API_BASE, GUEST_TOKEN, CLIENT_VERSION } from './constants.js';
|
||||
|
||||
/**
|
||||
* Returns request headers for the Bessa REST API.
|
||||
* @param {string|null} token - Auth token; falls back to GUEST_TOKEN if absent.
|
||||
* @returns {Object} HTTP headers for fetch()
|
||||
*/
|
||||
export function apiHeaders(token) {
|
||||
return {
|
||||
'Authorization': `Token ${token || GUEST_TOKEN}`,
|
||||
@@ -9,6 +19,11 @@ export function apiHeaders(token) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns request headers for the GitHub REST API v3.
|
||||
* Used for version checks and release listing.
|
||||
* @returns {Object} HTTP headers for fetch()
|
||||
*/
|
||||
export function githubHeaders() {
|
||||
return { 'Accept': 'application/vnd.github.v3+json' };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user