nocal2
v1.0.4
Published
A lightweight nodejs calendar library.
Maintainers
Readme
Nocal
A lightweight nodejs calendar library.
Features
- Create, read, update, and delete calendar events
- SQLite database persistence
- ICS (iCalendar) export and import
- RESTful API server
- Basic and Bearer authentication support
Installation
npm install nocalUsage
const nocal = require('nocal');
const cal = nocal.load('./calendar.db');
// Create an event
const eventId = await cal.createEvent({
title: 'My Event',
description: 'Description',
startDate: '2023-10-01T10:00:00Z',
endDate: '2023-10-01T11:00:00Z',
rrule: 'FREQ=WEEKLY;BYDAY=MO'
});
// List events
const events = await cal.listEvents();
// Start API server - various ways
const server1 = await cal.start(3000); // port only
const server2 = await cal.start(3000, 'localhost'); // port and host
const server3 = await cal.start(3000, () => console.log('Started')); // with callback
const server4 = await cal.start({ port: 3000, host: 'localhost', auth: { type: 'basic', username: 'user', password: 'pass' } }); // options objectAPI
Methods
load(dbPath): Load or create a calendar databasecreateEvent(eventData): Create a new eventlistEvents(): Get all eventsupdateEvent(id, updates): Update an eventremoveEvent(id): Delete an eventexportIcs(): Export events as ICSimportIcs(icsContent): Import events from ICSstart(port, callback): Start REST API server
API Endpoints
GET /events: List all eventsPOST /events: Create a new eventPUT /events/:id: Update an eventDELETE /events/:id: Delete an eventGET /export: Export as ICS
License
MIT
