npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ecosy/googleapis

v0.1.0

Published

Google APIs client (Drive, Auth, JWT) built on @ecosy/core Http

Readme

@ecosy/googleapis

Google APIs client (Drive, OAuth2, JWT) built on top of @ecosy/core/http. Works in Cloudflare Workers, Deno, Bun, Node, and modern browsers — authentication relies exclusively on the Web Crypto API.

Installation

yarn add @ecosy/googleapis @ecosy/core

Note: @ecosy/core ≥ 0.3.0 is required (for Endpoint, HttpUpload, and the related() upload method).

Subpath imports

| Entry point | Description | | ------------------------------------- | ------------------------------------------- | | @ecosy/googleapis | Re-exports all services and types | | @ecosy/googleapis/services/drive | Drive HTTP clients and file operations | | @ecosy/googleapis/services/auth | OAuth2 interceptor and token cache control | | @ecosy/googleapis/lib/jwt | createSignedJWT — RS256 via Web Crypto | | @ecosy/googleapis/types | TypeScript types |

Quick start

import {
  initDriveAuth,
  DriveService,
  uploadFileToDrive,
  trashFile,
  deleteFile,
} from "@ecosy/googleapis";

// 1. Wire the service-account credentials once at boot.
initDriveAuth({
  email: SERVICE_ACCOUNT_EMAIL,
  privateKey: PRIVATE_KEY_PEM,
  scope: "https://www.googleapis.com/auth/drive",
});

// 2. Use the Drive API.
const { data: list } = await DriveService.findFiles.fn({
  q: "'FOLDER_ID' in parents and trashed = false",
  fields: "files(id,name,mimeType)",
});

const { data: created } = await DriveService.createFile.fn({
  name: "note.txt",
  mimeType: "text/plain",
  parents: ["FOLDER_ID"],
});

// 3. Upload binary content with multipart/related.
await uploadFileToDrive("photo.jpg", "image/jpeg", bytes, "FOLDER_ID");

// 4. Trash or delete.
await trashFile(fileId);
await deleteFile(fileId);

API

Auth

  • initDriveAuth(config) — install the OAuth2 interceptor on driveHttp and uploadHttp. Idempotent.
  • createAuthInterceptor(config) — returns an HttpInterceptorRequest that injects Authorization: Bearer <token>. Tokens are cached in-memory with a 5-minute safety margin. Persistent caching (Redis, KV, disk, …) is an app-level concern and is not handled by this library.
  • invalidateTokenCache() — clear the in-memory token cache (e.g. after a 401).
interface GoogleAuthConfig {
  email: string;      // service-account client_email
  privateKey: string; // service-account private_key (PEM)
  scope: string;      // OAuth scopes, space-separated
}

Drive

  • driveHttp / uploadHttp — pre-configured Http instances pointing at drive/v3 and upload/drive/v3.
  • DriveService — typed endpoint factory:
    • DriveService.createFile.fn(payload)
    • DriveService.findFiles.fn(params)
    • DriveService.getStorageQuota.fn()
  • uploadFileToDrive(name, mimeType, bytes, folderId)multipart/related upload, returns the created DriveFile.
  • trashFile(fileId) — soft-delete by setting trashed: true.
  • deleteFile(fileId) — hard-delete.
  • getFileContent(fileId) — download as string.
  • updateFileContent(fileId, content, mimeType?) — media upload to an existing file.

Endpoints are registered via Endpoint.register("drive", …) from @ecosy/core/http, so custom factories can extend them.

JWT

  • createSignedJWT(email, privateKey, scope) — sign an RS256 JWT for the Google OAuth2 token exchange. Uses Web Crypto only; no Node built-ins.

Types

GoogleAuthConfig, CachedToken, DriveFile, DriveFileList, StorageQuota, FindFilesParams, CreateFilePayload, DeletedPhotoEntry, TrackingData.

Related packages

| Package | Description | |--|--| | @ecosy/core | Http client, Endpoint registry, utilities |

License

MIT