From d726c6a00f95438d0c69c94e0ccc37df9ed2011b Mon Sep 17 00:00:00 2001 From: Temidayo Gabriel Date: Sat, 2 May 2026 10:01:26 -0400 Subject: [PATCH 1/4] 0.1.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7298aa1..72388af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vfetch-client", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vfetch-client", - "version": "0.1.0", + "version": "0.1.1", "license": "MIT", "devDependencies": { "@types/node": "^25.6.0", diff --git a/package.json b/package.json index bbe9535..c203072 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vfetch-client", - "version": "0.1.0", + "version": "0.1.1", "description": "A modern Axios alternative built on native fetch with interceptors, automatic token refresh, retries, and predictable response handling", "type": "module", "main": "./dist/index.cjs", From 572bfb919d24e7eba257feb8d6005994da65e584 Mon Sep 17 00:00:00 2001 From: Temidayo Gabriel Date: Sat, 2 May 2026 11:20:24 -0400 Subject: [PATCH 2/4] chore: add license, and contribution guidelines etc --- .github/CONTRIBUTION.MD | 166 +++++++++++++++++++++++++++++++ .github/pull_request_template.md | 31 ++++++ .github/workflows/test.yml | 23 +++++ LICENSE.md | 25 +++++ package.json | 4 + 5 files changed, 249 insertions(+) create mode 100644 .github/CONTRIBUTION.MD create mode 100644 .github/pull_request_template.md create mode 100644 LICENSE.md diff --git a/.github/CONTRIBUTION.MD b/.github/CONTRIBUTION.MD new file mode 100644 index 0000000..8a3482c --- /dev/null +++ b/.github/CONTRIBUTION.MD @@ -0,0 +1,166 @@ +# πŸ“„ `CONTRIBUTING.md` + +````md +# Contributing to vfetch + +Thanks for your interest in contributing. + +This project is designed to be **strict, predictable, and production-grade**. Contributions must follow the guidelines below to be accepted. + +--- + +## πŸ› οΈ Getting Started + +Clone the repo and install dependencies: + +```bash +git clone https://github.com/Gab-codes/vfetch.git +cd vfetch +npm install +``` +```` + +Run tests: + +```bash +npm run test +``` + +Run coverage: + +```bash +npm run coverage +``` + +--- + +## πŸ“ Project Structure + +``` +src/ β†’ core implementation +tests/ β†’ unit tests +tests/integration/ β†’ integration tests +``` + +Do **not** mix concerns: + +- Unit tests stay in `tests/` +- Full flow / real API tests go in `tests/integration/` + +--- + +## πŸ“ Rules & Standards + +### 1. No breaking changes without discussion + +If your change alters behavior, open an issue first. + +--- + +### 2. Tests are mandatory + +- Every feature or fix **must include tests** +- No exceptions +- If it’s not tested, it won’t be merged + +--- + +### 3. Keep types strict + +- Avoid `any` unless absolutely necessary +- Prefer explicit types +- Maintain full TypeScript safety + +--- + +### 4. Do not modify unrelated code + +Only change what your PR is responsible for. + +--- + +### 5. Maintain existing design decisions + +This library prioritizes: + +- Predictable `{ ok: boolean }` responses +- No throwing for HTTP errors +- Transport-layer responsibility only (no schema validation) + +Do not introduce patterns that break this philosophy. + +--- + +### 6. Keep it lightweight + +This is a **zero-dependency** library. + +Do not add dependencies unless absolutely justified. + +--- + +## πŸ§ͺ Testing Guidelines + +- Use **Vitest** +- Use mocks for controlled behavior +- Keep tests isolated and deterministic +- Avoid unnecessary real API calls (only in integration tests) + +--- + +## πŸš€ Pull Request Process + +1. Fork the repo +2. Create a new branch: + + ```bash + git checkout -b feat/your-feature + ``` + +3. Make your changes +4. Add/Update tests +5. Ensure everything passes: + + ```bash + npm run coverage + ``` + +6. Open a PR + +--- + +## βœ… PR Requirements + +- All tests must pass +- Coverage must not decrease +- No TypeScript errors +- Clear description of what changed and why + +--- + +## ❌ What Will Be Rejected + +- PRs without tests +- Introducing unnecessary dependencies +- Weak typing (`any` abuse) +- Breaking core API design without discussion + +--- + +## πŸ’‘ Philosophy + +vfetch is built to be: + +- Predictable +- Lightweight +- Safe under concurrency + +Keep that in mind when contributing. + +--- + +## Thanks for contributing. + +``` + +``` diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..89e5fb6 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,31 @@ +## Description + +Briefly describe the changes introduced by this PR. Include any relevant background context. + +## Type of Change + +- [ ] New Feature +- [ ] Bug Fix +- [ ] Refactor (no functional changes) +- [ ] Documentation Update +- [ ] Configuration Change + +## Semantic Naming Verification + +- [ ] Does this PR follow the project's semantic naming convention? + +## Testing Report + +Please document how you tested your changes. + +### Automated Tests + +- [ ] npm test passes +- [ ] New unit/component tests added (if applicable) + +## Checklist + +- [ ] My code follows the project guidelines +- [ ] I have performed a self-review of my code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] My changes generate no new warnings diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8dc8e29..b80063a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: branches: [main] pull_request: branches: [main] + workflow_dispatch: jobs: test: @@ -31,3 +32,25 @@ jobs: - name: Run tests with coverage run: npm run coverage + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "20.x" + + - name: Install dependencies + run: npm ci + + - name: Build package + run: npm run build + + - name: Validate build output + run: | + test -f dist/index.js || exit 1 + test -f dist/index.cjs || exit 1 + test -f dist/index.d.ts || exit 1 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..eb09d19 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,25 @@ +# πŸ“„ `LICENSE` (MIT) + +```md +MIT License + +Copyright (c) 2026 Toru Gabriel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` diff --git a/package.json b/package.json index c203072..f16eb57 100644 --- a/package.json +++ b/package.json @@ -51,5 +51,9 @@ "tsup": "^8.5.1", "typescript": "^6.0.3", "vitest": "^4.1.5" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gab-codes" } } From df10d6ee1f53448d4e48cdfde280485917b601f3 Mon Sep 17 00:00:00 2001 From: Temidayo Gabriel Date: Sun, 3 May 2026 13:16:56 -0400 Subject: [PATCH 3/4] chores: Add CONTRIBUTING.md file and update readme --- .github/{CONTRIBUTION.MD => CONTRIBUTING.md} | 4 ---- README.md | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) rename .github/{CONTRIBUTION.MD => CONTRIBUTING.md} (99%) diff --git a/.github/CONTRIBUTION.MD b/.github/CONTRIBUTING.md similarity index 99% rename from .github/CONTRIBUTION.MD rename to .github/CONTRIBUTING.md index 8a3482c..05fe660 100644 --- a/.github/CONTRIBUTION.MD +++ b/.github/CONTRIBUTING.md @@ -160,7 +160,3 @@ Keep that in mind when contributing. --- ## Thanks for contributing. - -``` - -``` diff --git a/README.md b/README.md index 5040a5a..28b95f3 100644 --- a/README.md +++ b/README.md @@ -368,6 +368,12 @@ const { mutate } = useMutation({ --- +## Contributing + +Contributions are welcome. Please read the [Contributing Guide](.github/CONTRIBUTING.md) before opening a PR. + +--- + ## πŸ“„ License -MIT +MIT [License](LICENSE.md) From 56576350f6580c6f3cdab35ca38ca61e3eded0f3 Mon Sep 17 00:00:00 2001 From: Temidayo Gabriel Date: Sun, 3 May 2026 14:04:35 -0400 Subject: [PATCH 4/4] fix(api response): fix api response to defualt to any if no type is passed --- src/client.ts | 12 ++++++------ src/index.ts | 9 +++++++-- src/types.ts | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/client.ts b/src/client.ts index d583a1f..ea563b5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -69,7 +69,7 @@ export class VfetchClient { /** * Internal request handler that implements the full request lifecycle. */ - private async request( + private async request( path: string, options: RequestOptions & { method: string; @@ -278,7 +278,7 @@ export class VfetchClient { * @param path - The URL path relative to baseURL * @param options - Optional request configuration */ - async get(path: string, options?: RequestOptions): Promise> { + async get(path: string, options?: RequestOptions): Promise> { return this.request(path, { ...options, method: "GET" }); } @@ -289,7 +289,7 @@ export class VfetchClient { * @param body - The request body, serialized as JSON * @param options - Optional request configuration */ - async post(path: string, body?: unknown, options?: RequestOptions): Promise> { + async post(path: string, body?: unknown, options?: RequestOptions): Promise> { return this.request(path, { ...options, method: "POST", body }); } @@ -300,7 +300,7 @@ export class VfetchClient { * @param body - The request body, serialized as JSON * @param options - Optional request configuration */ - async patch(path: string, body?: unknown, options?: RequestOptions): Promise> { + async patch(path: string, body?: unknown, options?: RequestOptions): Promise> { return this.request(path, { ...options, method: "PATCH", body }); } @@ -311,7 +311,7 @@ export class VfetchClient { * @param body - The request body, serialized as JSON * @param options - Optional request configuration */ - async put(path: string, body?: unknown, options?: RequestOptions): Promise> { + async put(path: string, body?: unknown, options?: RequestOptions): Promise> { return this.request(path, { ...options, method: "PUT", body }); } @@ -321,7 +321,7 @@ export class VfetchClient { * @param path - The URL path relative to baseURL * @param options - Optional request configuration */ - async delete(path: string, options?: RequestOptions): Promise> { + async delete(path: string, options?: RequestOptions): Promise> { return this.request(path, { ...options, method: "DELETE" }); } } diff --git a/src/index.ts b/src/index.ts index 169efbc..0330f5f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,11 +15,16 @@ import { VfetchConfig } from "./types"; * ```ts * const api = createClient({ * baseURL: "https://api.example.com", - * timeout: 5000, - * retry: 3, + * timeout: 5000, // optional - request timeout in ms + * retry: 3, // optional - retry network failures up to 3 times + * retryDelay: 1000, // optional - delay between retries in ms * }); * + * // With type annotation (fully typed) * const result = await api.get("/users"); + * + * // Without type annotation (response.data defaults to 'any') + * const result = await api.get("/users"); * ``` */ export function createClient(config: VfetchConfig): VfetchClient { diff --git a/src/types.ts b/src/types.ts index 85483f0..4deb115 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,7 +2,7 @@ * Represents a successful response from vfetch. * @template T The type of the data returned by the server. */ -export interface VfetchSuccess { +export interface VfetchSuccess { /** Indicates the request was successful. */ readonly ok: true; /** The parsed JSON data from the response. */ @@ -27,7 +27,7 @@ export interface VfetchError> { /** * The union type of all possible vfetch responses. */ -export type VfetchResponse = VfetchSuccess | VfetchError; +export type VfetchResponse = VfetchSuccess | VfetchError; /** * Configuration options for the vfetch client instance.