Skip to content

Commit

Permalink
Append hebcal-web version number to JSON version string
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Oct 29, 2024
1 parent 179d8ee commit 8e4492e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hebcal-web",
"version": "3.1.4",
"version": "3.1.5",
"description": "Hebcal server-side Node.js for www.hebcal.com and download.hebcal.com",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions src/hebcal.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ import dayjs from 'dayjs';
import localeData from 'dayjs/plugin/localeData.js';
import './dayjs-locales.js';
import '@hebcal/locales';
import {readJSON} from './readJSON.js';

dayjs.extend(localeData);

const pkg = readJSON('../package.json');

export async function hebcalApp(ctx) {
if (ctx.method === 'POST') {
ctx.set('Allow', 'GET');
Expand Down Expand Up @@ -436,6 +439,9 @@ function renderJson(ctx) {
options.heDateParts = true;
}
let obj = eventsToClassicApi(events, options, !leyningOff);
if (typeof obj.version === 'string') {
obj.version += '-' + pkg.version;
}
const cb = empty(q.callback) ? false : q.callback.replace(/[^\w\.]/g, '');
if (cb) {
obj = cb + '(' + JSON.stringify(obj) + ')\n';
Expand Down
6 changes: 6 additions & 0 deletions src/shabbat.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ import utc from 'dayjs/plugin/utc.js';
import timezone from 'dayjs/plugin/timezone.js';
import './dayjs-locales.js';
import {GeoDb} from '@hebcal/geo-sqlite';
import {readJSON} from './readJSON.js';

dayjs.extend(utc);
dayjs.extend(timezone);

const pkg = readJSON('../package.json');

const BASE_URL = 'https://www.hebcal.com/shabbat';

export async function shabbatApp(ctx) {
Expand Down Expand Up @@ -82,6 +85,9 @@ export async function shabbatApp(ctx) {
ctx.state.options.heDateParts = true;
}
let obj = eventsToClassicApi(ctx.state.events, ctx.state.options, !leyningOff);
if (typeof obj.version === 'string') {
obj.version += '-' + pkg.version;
}
const cb = empty(q.callback) ? false : q.callback.replace(/[^\w\.]/g, '');
if (cb) {
obj = cb + '(' + JSON.stringify(obj) + ')\n';
Expand Down
6 changes: 6 additions & 0 deletions src/yahrzeit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ import {getMaxYahrzeitId, isNumKey, summarizeAnniversaryTypes,
import {makeLogInfo} from './logger.js';
import {isDeepStrictEqual} from 'node:util';
import {murmur128HexSync, murmur32HexSync} from 'murmurhash3';
import {readJSON} from './readJSON.js';

const urlPrefix = process.env.NODE_ENV == 'production' ? 'https://download.hebcal.com' : 'http://127.0.0.1:8081';

const pkg = readJSON('../package.json');

/**
* @param {*} ctx
* @return {*}
Expand Down Expand Up @@ -211,6 +214,9 @@ async function renderJson(maxId, q) {
options.heDateParts = true;
}
const results = eventsToClassicApi(events, options, false);
if (typeof results.version === 'string') {
results.version += '-' + pkg.version;
}
for (const item of results.items) {
delete item.hebrew;
delete item.category;
Expand Down

0 comments on commit 8e4492e

Please sign in to comment.