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 🙏

© 2024 – Pkg Stats / Ryan Hefner

calenduh

v1.5.0

Published

Node.js Wrapper for Google Calendar API

Downloads

13

Readme

Calenduh

Node.js wrapper for Google Calendar API

This is a small wrapper to make working with Google Calendar API mor convenient and faster.

The main focus is to abstract the authentication process and management.

! Attention !

The authentication process requires the first-time user to click on a link in their terminal, accept access to their calendar and copy a verification code into their terminal. At this point it isn't possible to do this another way. That's why the use cases are mostly command line tools right now.

Install

npm install calenduh

Getting Started

Google requires you to register an application in order to work with their APIs.

You can use this guide to generate a client_secret.json which will contain all necessary information.

With the secret file you can instantiate Calenduh:

const Calenduh = require('calenduh');
const cal = new Calenduh('./path/to/client_secret.json');

Methods

calendarList()

Returns a promise with and array of all calendars of the authenticated user.

cal.calendarList()
    .then((lists) => {
        // ...
    });

events(calendarId, opts)

Returns all events from a specific calendar. The options are passed directly to the Google Calendar API, all defaults and parameters can be found here.

cal.events(calendarId, {
    timeMin: (new Date('2017-02-01')).toISOString(),
    timeMax: (new Date('2017-02-28')).toISOString(),
}).then((events) => {
    // ...
});

allEvents(opts)

Returns a list of all events from all calendars. Options behave the same way as in events().

cal.allEvents({})
    .then((events) => {
        // ...
    });

createCalendar(name)

Create a new calendar with the passed name. Returns new calendar.

cal.createCalendar('My new Calendar')
    .then((calendar) => {
        // ...
    });

findOrCreateCalendar(name)

Checks if calendar with passed name already exists. If it does it will be returned. If not the calendar will be created and returned.

cal.findOrCreateCalendar('My Calendar')
    .then((calendar) => {
        // ...
    });

createEvent(calendarId, name, startDateTime, endDateTime, [opts])

Creates an event for a specific calendar and returns it. startDateTime and endDateTime are required, additonal data can be passed in opts object. Full list of available options can be found in the official documentation.

cal.createEvent(
    calendarId,
    'My Event',
    '2017-02-21T10:00:00.000Z',
    '2017-02-21T12:00:00.000Z',
    {
        location: 'My Location',
    }
).then((event) => {
    // ...
});

createEvents(calendarId, events)

Creates multiple events. There is an artificial timeout between each request to give the api time to process, currently there is no better solution for this. events is an array, each object has to have the following structure:

{
    name: 'Name of event',
    start: '2017-02-21T10:00:00.000Z',
    end: '2017-02-21T10:00:00.000Z',
    opts: {
        location: 'My Location',
    }
}

Usage:

cal.createEvents(calendarId, events)
    .then(() => {
        // ...
    });

deleteEvent(calendarId, eventId)

Deletes single event by Id, requires the Id of the parent calendar.

cal.deleteEvent(calendarId, eventId)
    .then(() => {
        // ...
    });

deleteEvents(calendarId, eventIds = [])

Deletes multiple events by Id. This is simply a convenient function which performs multiple deleteEvent() calls.

cal.deleteEvents(calendarId, eventIds)
    .then(() => {
        // ...
    });