github-typesafe-sdk-next
v1.0.2
Published
A TypeSafe GitHub SDK written in TypeScript
Maintainers
Readme
GitHub TypeSafe SDK
A small TypeScript SDK to fetch GitHub user data with type safety.
It returns only the selected fields of a GitHub user (login, id, avatar_url) for simplicity.
Installation
Install via npm:
npm install github-typesafe-sdk-nextUsage
Import the SDK and fetch GitHub user data:
import { GitHubSDK } from "github-typesafe-sdk-next";
async function run() {
const user = await GitHubSDK.getUser("torvalds");
console.log("Username:", user.login);
console.log("ID:", user.id);
console.log("Avatar URL:", user.avatar_url);
}
run();Example Output
{
"login": "torvalds",
"id": 1024025,
"avatar_url": "https://avatars.githubusercontent.com/u/1024025?v=4"
}Returned Data
The getUser method returns a TypeScript object with this interface:
interface GitHubUser {
login: string;
id: number;
avatar_url: string;
}Extra fields from GitHub’s API are ignored to keep the SDK simple and type-safe.
Development
Build the project with:
npm run buildThe compiled files are output to the dist/ folder.
License
MIT
