Skip to content

Instantly share code, notes, and snippets.

View realChakrawarti's full-sized avatar

Anupam Chakrawarti realChakrawarti

View GitHub Profile
@realChakrawarti
realChakrawarti / try-catch.ts
Created March 20, 2025 16:11 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@realChakrawarti
realChakrawarti / create-endpoint.ts
Created January 11, 2025 07:37
Create API endpoint
/**
* Represents possible types for path parameters in URLs
*/
type PathParam = string | number;
/**
* Represents possible types for query parameter values
*/
type QueryValue = string | number | boolean | (string | number | boolean)[];
@realChakrawarti
realChakrawarti / main.ts
Last active October 10, 2024 18:49
YouTube Topic Ids
// import topicIds from "./youtube-topics.json" with { type: "json" };
// Refer: https://developers.google.com/youtube/v3/docs/search/list
const topicIds = [
{
id: "/m/04rlf",
topic: "Music",
parent: true,
},
{