Skip to content

Instantly share code, notes, and snippets.

View jsonbytes's full-sized avatar
🎨
Creating

Jason jsonbytes

🎨
Creating
  • 01:31 (UTC -06:00)
View GitHub Profile
@jsonbytes
jsonbytes / gist:d4a8b59a7de68507dab42a9544564f26
Created December 4, 2023 13:37
General purpose API Client
import axios, {
AxiosError,
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
InternalAxiosRequestConfig,
} from "axios";
import { API_BASE_URI } from "../config/apiConfig";
import { ErrorResponse, FetchResponse } from "@sapience/common";
@jsonbytes
jsonbytes / gist:94f2b056a2b945bf876a5dbbe082901a
Created November 30, 2023 11:21
Fullstack monorepo init command(s)
mkdir jsonbytes-monorepo
cd jsonbytes-monorepo
npm init -y
npm init -y --scope @jsonbytes -w packages/core
npm init -y --scope @jsonbytes -w packages/database
nest new -g -s -p npm --directory packages/api @jsonbytes/api
npm init -y --scope @jsonbytes -w packages/api
npm install @jsonbytes/core -w @jsonbytes/api
@jsonbytes
jsonbytes / gist:6216eb6057cd8ac2421a453dcbcd3743
Created November 22, 2023 01:21
Generate index.ts files for module exports
import * as fs from "fs/promises";
import * as path from "path";
// usage (compiled)
// node dist/index-generator.js /home/jason/Development/project/src/moduledirectory
const generateIndex = async (folderPath: string) => {
try {
const files = await fs.readdir(folderPath);
const exportStatements = files
@jsonbytes
jsonbytes / apiClient.ts
Created November 21, 2023 20:18
API Client written in Typescript
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from "axios";
import { API_BASE_URL } from "../config/apiConfig";
class APIClient<T> {
private axiosInstance: AxiosInstance;
endpoint: string;
constructor(endpoint: string) {
this.endpoint = endpoint;
this.axiosInstance = axios.create({ baseURL: API_BASE_URL });