New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@william-pack/googleapis

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@william-pack/googleapis

A serverless API that integrates with Google Drive and Firebase Realtime Database to manage file storage and real-time data synchronization. Built for seamless authentication, secure data handling, and efficient cloud operations.

1.0.0
latest
Source
npm
Version published
Weekly downloads
57
Maintainers
0
Weekly downloads
 
Created
Source

GoogleAPI Library

Features

  • Google Drive API v3 support
  • Google Realtime Database support
  • Uses fetch for HTTP requests
  • Supports caching access tokens

Installation

Install via npm:

npm install @william-pack/googleapis

or using bun:

bun add @william-pack/googleapis

Usage

Import the Library

ESM

import { GoogleAuth } from "@william-pack/googleapis";

CommonJS

const { GoogleAuth } = require("@william-pack/googleapis");

Initialize API

Support Google Service Account only

const auth = new GoogleAuth({
    credential: {
        project_id: "your_project_id",
        private_key: "your_private_key",
        client_email: "your_client_email"
    }
});

Google Drive API

import { GoogleDrive } from "@william-pack/googleapis";
const drive = new GoogleDrive( auth, ['your_google_drive_folder_id'] );

Create a File

const file = new File(["Hello World"], "hello.txt", { type: "text/plain" });
await drive.create( file );
// return id: string

Remove a File

await drive.remove("your_file_id");
// return file is removed: true | false

Find All Files

await drive.findAll();
// return files: { id:string, name: string }[]

Google Realtime Database API

import { GoogleDatabase } from "@william-pack/googleapis";
const database = new GoogleDatabase( auth, "your_database_url" );

Create Data

await database.create("/path/to/data", { key: "value" });
// return your data

type save data

await database.create<{ key: type }>("/path/to/data", { username:"..." })

Remove Data

await database.remove("/path/to/data");
// return data is removed: true | false

Find All Data

await database.findAll("/path/to/data");
// reurn data

type save response

await database.findAll<{ key: type }>("/path/to/data");

Query Data

await database.query("/path/to/data", {
    orderBy: "your_data_key",
    equalTo: "your_data_value"
});
// return data

type save response

await database.query<{ key: type }>("/path/to/data", {
    orderBy: "your_data_key",
    equalTo: "your_data_value"
});

Transaction

await database.transaction("/path/to/data", ( currentData ) => {
    return { ...currentData, updatedKey: "newValue" };
});
// return data

type save data

await database.transaction<{ key: type }>("/path/to/data", ( currentData ) => {
    return { ...currentData, updatedKey: "newValue" };
});

Repository

GitHub Repository

License

This project is licensed under the MIT License.

Keywords

google

FAQs

Package last updated on 05 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts