A TypeScript library for generating OPDS feeds (v1.2) with a fluent API. Designed to be extendable for future OPDS v2 support.
Feed
and Entry
objects.self
, start
).npm install opds-ts
This is an example on how to create a simple feed:
import { Feed } from 'opds-ts';
import { Entry } from 'opds-ts';
const baseUrl = 'https://example.com';
const feed = new Feed('books', 'All Books')
.setLang('en')
.setAuthor('The Library of Babel')
.setKind('navigation')
.addSelfLink('/opds', 'navigation')
.addStartLink('/opds');
const entry = new Entry('book:1', 'The Lord of the Rings')
.setAuthor('J. R. R. Tolkien')
.setSummary(
'A ring with mysterious powers lands in the hands of a young hobbit, Frodo. Under the guidance of Gandalf, a wizard, he and his three friends set out on a journey and land in the Elvish kingdom.'
)
.addAcquisition('/entry/1/acquisition', 'application/epub+zip')
.addImage('/data/covers/1.jpg');
feed.addEntry(entry);
const xml = feed.toXml({ baseUrl, prettyPrint: true });
console.log(xml);
This project is licensed under the MIT License - see the LICENSE file for details.