From c538200b682dab8e3829b8c6fee14c55ecdb2888 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Thu, 25 Jan 2024 18:18:48 -0600 Subject: [PATCH 1/2] feat: bump deps, fixed rootRoute issue (support URL) --- .gitignore | 10 ++++++++++ package.json | 43 ++++++++++++++++++++-------------------- src/common/eventBuild.ts | 3 +-- src/index.ts | 1 + src/koa.ts | 3 ++- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index c225d08..24b5d10 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,13 @@ package-lock.json example/config.js example/runData.json lib/ +src/index.js +src/koa.js +src/common/date.js +src/common/eventBuild.js +src/common/parseBody.js +src/common/response.js +src/common/tags.js +src/common/winston.js +src/common/xBuild.js +src/common/xml.js diff --git a/package.json b/package.json index 6420a2b..01c3ba6 100644 --- a/package.json +++ b/package.json @@ -22,32 +22,33 @@ }, "devDependencies": { "@types/ical": "^0.6.1", - "@types/koa": "^2.11.3", - "@types/lodash": "^4.14.151", - "@types/node": "^14.0.1", - "@types/xmldom": "^0.1.29", - "@typescript-eslint/eslint-plugin": "^2.31.0", - "@typescript-eslint/parser": "^2.31.0", - "eslint": "^6.8.0", - "koa": "^2.11.0", - "koa-compress": "^4.0.1", + "@types/koa": "^2.13.12", + "@types/lodash": "^4.14.202", + "@types/node": "^20.10.6", + "@types/xmldom": "^0.1.34", + "@typescript-eslint/eslint-plugin": "^6.16.0", + "@typescript-eslint/parser": "^6.16.0", + "eslint": "^8.56.0", + "koa": "^2.15.0", + "koa-compress": "^5.1.1", "koa-morgan": "^1.0.1", - "nodemon": "^2.0.4", - "typescript": "^3.9.2" + "nodemon": "^3.0.2", + "typescript": "^5.3.3" }, "dependencies": { "basic-auth": "^2.0.1", "ical": "^0.8.0", "ical-generator": "^1.10.0", - "lodash": "^4.17.15", - "moment": "^2.25.3", - "moment-timezone": "^0.5.28", - "path-to-regexp": "^6.1.0", - "raw-body": "^2.4.1", - "rrule": "^2.6.4", - "winston": "^3.2.0", - "xmlbuilder2": "^2.1.2", - "xmldom": "^0.3.0", - "xpath": "0.0.27" + "lodash": "^4.17.21", + "moment": "^2.30.1", + "moment-timezone": "^0.5.44", + "path-to-regexp": "^6.2.1", + "raw-body": "^2.5.2", + "rrule": "^2.8.1", + "validator": "^13.11.0", + "winston": "^3.11.0", + "xmlbuilder2": "^3.1.1", + "xmldom": "^0.6.0", + "xpath": "0.0.34" } } diff --git a/src/common/eventBuild.ts b/src/common/eventBuild.ts index 1bc57b6..2977329 100644 --- a/src/common/eventBuild.ts +++ b/src/common/eventBuild.ts @@ -99,7 +99,6 @@ export default function(opts: CalDavOptionsModule) { } } const events = [evt, ...recur]; - const cal = ical({ domain: FIXED_DOMAIN, prodId: opts.proId, @@ -133,7 +132,7 @@ export default function(opts: CalDavOptionsModule) { } if (parsed.rrule) { obj.recurring = { - freq: rrule.FREQUENCIES[parsed.rrule.origOptions.freq] + freq: rrule.RRule.FREQUENCIES[parsed.rrule.origOptions.freq] }; if (parsed.rrule.origOptions.until) { obj.recurring.until = formatted(parsed.rrule.origOptions.until); diff --git a/src/index.ts b/src/index.ts index b742ddd..e6ea93a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,6 +30,7 @@ export type CalDavRecurrence = { createdOn?: string; lastModifiedOn?: string; }; + export type CalDavRecurring = { freq: 'SECONDLY' | 'MINUTELY' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY' | 'HOURLY'; until?: string; diff --git a/src/koa.ts b/src/koa.ts index e1ca30a..84008e7 100644 --- a/src/koa.ts +++ b/src/koa.ts @@ -6,6 +6,7 @@ import parseBody from './common/parseBody'; import winston from './common/winston'; import cal from './routes/calendar/calendar'; import pri from './routes/principal/principal'; +import { isURL } from 'validator'; import { Request, ParameterizedContext } from 'koa'; import { FullCalendar } from 'ical'; @@ -44,7 +45,7 @@ export default function(opts: CalDavOptions) { const log = winston({ ...opts, label: 'index' }); - const rootRoute = path.join('/', opts.caldavRoot); + const rootRoute = isURL(opts.caldavRoot) ? path.join(opts.caldavRoot, '/') : path.join('/', opts.caldavRoot); const calendarRoute = path.join(rootRoute, opts.calendarRoot); const principalRoute = path.join(rootRoute, opts.principalRoot, '/'); From 4f5a2bb5e958dd130d60a9167d4a1edaa29b21b2 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Thu, 25 Jan 2024 19:03:56 -0600 Subject: [PATCH 2/2] fix: removed validator and url usage --- package.json | 1 - src/koa.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 01c3ba6..2de5e1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "path-to-regexp": "^6.2.1", "raw-body": "^2.5.2", "rrule": "^2.8.1", - "validator": "^13.11.0", "winston": "^3.11.0", "xmlbuilder2": "^3.1.1", "xmldom": "^0.6.0", diff --git a/src/koa.ts b/src/koa.ts index 84008e7..e1ca30a 100644 --- a/src/koa.ts +++ b/src/koa.ts @@ -6,7 +6,6 @@ import parseBody from './common/parseBody'; import winston from './common/winston'; import cal from './routes/calendar/calendar'; import pri from './routes/principal/principal'; -import { isURL } from 'validator'; import { Request, ParameterizedContext } from 'koa'; import { FullCalendar } from 'ical'; @@ -45,7 +44,7 @@ export default function(opts: CalDavOptions) { const log = winston({ ...opts, label: 'index' }); - const rootRoute = isURL(opts.caldavRoot) ? path.join(opts.caldavRoot, '/') : path.join('/', opts.caldavRoot); + const rootRoute = path.join('/', opts.caldavRoot); const calendarRoute = path.join(rootRoute, opts.calendarRoot); const principalRoute = path.join(rootRoute, opts.principalRoot, '/');