Skip to content

Commit

Permalink
Include a version field in classic rest API response
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Oct 20, 2024
1 parent ea045f5 commit 13ced49
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/rest-api",
"version": "5.1.4",
"version": "5.2.0",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal"
Expand Down
2 changes: 2 additions & 0 deletions src/classic-rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Zmanim,
flags,
gematriya,
version,
} from '@hebcal/core';
import {isoDateString} from '@hebcal/hdate';
import {
Expand Down Expand Up @@ -45,6 +46,7 @@ export function eventsToClassicApi(
const result: any = {
title: getCalendarTitle(events, options),
date: new Date().toISOString(),
version,
};
result.location = locationToPlainObj(options.location);
if (events.length) {
Expand Down
3 changes: 3 additions & 0 deletions test/classic-rest-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ test('classic-api-no-sedra', () => {
const events = HebrewCalendar.calendar(options);
const apiResult = eventsToClassicApi(events, options);
delete apiResult.date;
delete apiResult.version;
for (const item of apiResult.items) {
delete item.memo;
}
Expand Down Expand Up @@ -463,6 +464,7 @@ test('location-zip', () => {
const ev = new HebrewDateEvent(new HDate(new Date(2022, 2, 4)));
const apiResult = eventsToClassicApi([ev], {location});
delete apiResult.date;
delete apiResult.version;
const expected = {
title: 'Hebcal Providence March 2022',
location: {
Expand Down Expand Up @@ -530,6 +532,7 @@ test('omer', () => {
test('classic-api-empty', () => {
const apiResult = eventsToClassicApi([], {}, false);
delete apiResult.date;
delete apiResult.version;
const expected = {
title: 'Hebcal Diaspora',
location: {geo: 'none'},
Expand Down

0 comments on commit 13ced49

Please sign in to comment.