A decentralized music tracking and discovery platform built on AT Protocol 馃幍
at feat/feed-generator 42 lines 940 B view raw
1import axios from "axios"; 2import { API_URL } from "../consts"; 3import { ApiKey } from "../types/apikey"; 4 5const headers = { 6 authorization: `Bearer ${localStorage.getItem("token")}`, 7}; 8 9export const createApiKey = async (name: string, description?: string) => { 10 return await axios.post<ApiKey>( 11 `${API_URL}/apikeys`, 12 { name, description }, 13 { headers }, 14 ); 15}; 16 17export const getApiKeys = async (offset = 0, size = 20) => { 18 return await axios.get<ApiKey[]>(`${API_URL}/apikeys`, { 19 headers, 20 params: { 21 offset, 22 size, 23 }, 24 }); 25}; 26 27export const deleteApiKey = async (id: string) => { 28 return await axios.delete(`${API_URL}/apikeys/${id}`, { headers }); 29}; 30 31export const updateApiKey = async ( 32 id: string, 33 enabled: boolean, 34 name?: string, 35 description?: string, 36) => { 37 return await axios.put<ApiKey>( 38 `${API_URL}/apikeys/${id}`, 39 { name, description, enabled }, 40 { headers }, 41 ); 42};