diff --git a/package.json b/package.json
index 0957497c..81209697 100644
--- a/package.json
+++ b/package.json
@@ -25,11 +25,11 @@
"fix:prettier": "prettier --write src"
},
"devDependencies": {
- "@book000/node-utils": "1.3.57",
+ "@book000/node-utils": "1.4.0",
"@fastify/basic-auth": "5.0.0",
"@fastify/cors": "8.3.0",
"@types/cheerio": "0.22.31",
- "@types/node": "20.2.6",
+ "@types/node": "20.5.0",
"@types/web-push": "3.3.2",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
@@ -44,7 +44,7 @@
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-unicorn": "48.0.1",
"fastify": "4.21.0",
- "prettier": "2.8.8",
+ "prettier": "3.0.2",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "5.1.6",
@@ -52,4 +52,4 @@
"web-push": "3.6.4",
"yarn-run-all": "3.1.1"
}
-}
\ No newline at end of file
+}
diff --git a/src/main.ts b/src/main.ts
index 79c22733..b8a3e5c4 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -34,7 +34,7 @@ function getDirectionText(direction: SyslogCall['direction']): string {
function getStatusText(
status: SyslogCall['status'],
- direction: SyslogCall['direction']
+ direction: SyslogCall['direction'],
): string {
switch (status) {
case 'connected': {
@@ -61,13 +61,13 @@ function getCallerName(callerResult: PhoneDetailResult) {
function getIDestinations(
config: Configuration,
- detail: CallDetail
+ detail: CallDetail,
): IDestination[] | null {
const destination = config.destinations.filter((d) =>
Object.entries(d.condition).every(
// @ts-ignore
- ([key, value]) => new RegExp(value).test(detail[key])
- )
+ ([key, value]) => new RegExp(value).test(detail[key]),
+ ),
)
if (destination) {
return destination
@@ -79,8 +79,8 @@ function getSelfName(config: Configuration, detail: CallDetail): string {
const self = config.selfs.find((d) =>
Object.entries(d.condition).every(
// @ts-ignore
- ([key, value]) => new RegExp(value).test(detail[key])
- )
+ ([key, value]) => new RegExp(value).test(detail[key]),
+ ),
)
if (self) {
return self.name
@@ -94,7 +94,7 @@ function getNotGoogleSearchMessage(
callerNumber: string,
callerName: string,
source: string,
- selfName: string
+ selfName: string,
): string {
return [
`☎ **【${connectedText}】${directionText} \`${callerName}\` (\`${callerNumber}\`)**`,
@@ -111,10 +111,10 @@ function getGoogleSearchMessage(
callerName: string,
source: string,
selfName: string,
- googleResult: GoogleSearchResult
+ googleResult: GoogleSearchResult,
) {
const googleResults = googleResult.items.map(
- (item, index) => `#${index + 1} \`${item.title}\` ${item.url}`
+ (item, index) => `#${index + 1} \`${item.title}\` ${item.url}`,
)
return [
`☎ **【${connectedText}】${directionText} \`${callerName}\` (\`${callerNumber}\`)**`,
@@ -134,22 +134,22 @@ async function checker(config: Configuration) {
const nvr510 = new NVR510(
config.router.ip,
config.router.username,
- config.router.password
+ config.router.password,
)
const calls = await nvr510.getCallsFromSyslog()
const filteredCalls = calls.filter(
- (call) => !Checked.isChecked(call.date, call.time)
+ (call) => !Checked.isChecked(call.date, call.time),
)
logger.info(
- `📞 calls: ${calls.length}, filteredCalls: ${filteredCalls.length}`
+ `📞 calls: ${calls.length}, filteredCalls: ${filteredCalls.length}`,
)
for (const call of filteredCalls.reverse()) {
const directionText = getDirectionText(call.direction)
const connectedText = getStatusText(call.status, call.direction)
logger.info(
- `📞 ${directionText} ${call.fromNumber} -> ${call.toNumber} (${connectedText})`
+ `📞 ${directionText} ${call.fromNumber} -> ${call.toNumber} (${connectedText})`,
)
// 着信だったら、toNumber、発信だったら、fromNumber がこっち側の番号
@@ -184,7 +184,7 @@ async function checker(config: Configuration) {
callerName,
source,
selfName,
- callerResult
+ callerResult,
)
: getNotGoogleSearchMessage(
connectedText,
@@ -192,7 +192,7 @@ async function checker(config: Configuration) {
callerNumber,
callerName,
source,
- selfName
+ selfName,
)
if (!isFirst && destinations.length > 0) {
diff --git a/src/public/index.html b/src/public/index.html
index e11d0d83..01b46eff 100644
--- a/src/public/index.html
+++ b/src/public/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/src/public/script.js b/src/public/script.js
index 1d209856..c936cf41 100644
--- a/src/public/script.js
+++ b/src/public/script.js
@@ -81,7 +81,7 @@ async function subscribe(destinationName) {
worker.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: validPublicKey,
- })
+ }),
)
const subscriptionJSON = currentLocalSubscription.toJSON()
diff --git a/src/public/style.css b/src/public/style.css
index 9ae8a703..c20d6737 100644
--- a/src/public/style.css
+++ b/src/public/style.css
@@ -107,7 +107,9 @@ button#unsubscribe {
background-color: rgba(0, 0, 0, 0.5);
z-index: 1;
- transition: opacity 1s, visibility 1s;
+ transition:
+ opacity 1s,
+ visibility 1s;
opacity: 0;
visibility: hidden;
}
diff --git a/src/utils/config.ts b/src/utils/config.ts
index 007582a3..936f2746 100644
--- a/src/utils/config.ts
+++ b/src/utils/config.ts
@@ -145,13 +145,13 @@ const isConfig = (config: any): config is Configuration => {
}
export const isDestinationDiscordWebhook = (
- destination: any
+ destination: any,
): destination is DestinationDiscordWebhook => {
return destination.type === 'discord-webhook' && !!destination.webhook_url
}
export const isDestinationDiscordBot = (
- destination: any
+ destination: any,
): destination is DestinationDiscordBot => {
return (
destination.type === 'discord-bot' &&
@@ -161,19 +161,19 @@ export const isDestinationDiscordBot = (
}
export const isDestinationSlack = (
- destination: any
+ destination: any,
): destination is DestinationSlack => {
return destination.type === 'slack' && !!destination.webhook_url
}
export const isDestinationLINENotify = (
- destination: any
+ destination: any,
): destination is DestinationLINENotify => {
return destination.type === 'line-notify' && !!destination.token
}
export const isDestinationWebPush = (
- destination: any
+ destination: any,
): destination is DestinationWebPush => {
return destination.type === 'web-push'
}
diff --git a/src/utils/destination.ts b/src/utils/destination.ts
index cdc56785..62ae05c6 100644
--- a/src/utils/destination.ts
+++ b/src/utils/destination.ts
@@ -12,7 +12,7 @@ import { WebPush } from './web-push'
class BaseDestination {
public async send(message: string): Promise {
throw new Error(
- `Not implemented: ${this.constructor.name}.send() ${message}`
+ `Not implemented: ${this.constructor.name}.send() ${message}`,
)
}
}
@@ -33,7 +33,7 @@ class DiscordWebhookDestination extends BaseDestination {
class DiscordBotDestination extends BaseDestination {
constructor(
private readonly token: string,
- private readonly channelId: string
+ private readonly channelId: string,
) {
super()
}
@@ -47,7 +47,7 @@ class DiscordBotDestination extends BaseDestination {
Authorization: `Bot ${this.token}`,
},
validateStatus: () => true,
- }
+ },
)
if (response.status !== 204 && response.status !== 200) {
throw new Error(`Discord webhook failed (${response.status})`)
@@ -66,7 +66,7 @@ class SlackDestination extends BaseDestination {
{ text: message },
{
validateStatus: () => true,
- }
+ },
)
if (response.status !== 200) {
throw new Error(`Slack webhook failed (${response.status})`)
@@ -89,7 +89,7 @@ class LINENotifyDestination extends BaseDestination {
headers: {
Authorization: `Bearer ${this.token}`,
},
- }
+ },
)
if (response.status !== 200) {
throw new Error(`LINE Notify failed (${response.status})`)
diff --git a/src/utils/nvr510.ts b/src/utils/nvr510.ts
index 92d8b387..4db16d32 100644
--- a/src/utils/nvr510.ts
+++ b/src/utils/nvr510.ts
@@ -61,7 +61,7 @@ export class NVR510 {
username: this.username,
password: this.password,
},
- }
+ },
)
if (response.status !== 200) {
throw new Error(`Failed to get syslog: ${response.status}`)
diff --git a/src/utils/search-number.ts b/src/utils/search-number.ts
index a3c2354e..8531b4d9 100644
--- a/src/utils/search-number.ts
+++ b/src/utils/search-number.ts
@@ -161,7 +161,7 @@ class GoogleSearch extends BaseSearchNumber {
export async function searchNumber(
config: Configuration,
- number: string
+ number: string,
): Promise {
const logger = Logger.configure('GoogleSearch::searchNumber')
const searchers = [
@@ -183,13 +183,13 @@ export async function searchNumber(
}
export function isPhoneDetail(
- result: PhoneDetailResult
+ result: PhoneDetailResult,
): result is PhoneDetail {
return result !== null && 'name' in result
}
export function isGoogleSearchResult(
- result: PhoneDetailResult
+ result: PhoneDetailResult,
): result is GoogleSearchResult {
return result !== null && 'count' in result
}
diff --git a/src/utils/web-push.ts b/src/utils/web-push.ts
index ae9a2f1a..e40527f8 100644
--- a/src/utils/web-push.ts
+++ b/src/utils/web-push.ts
@@ -36,8 +36,8 @@ export class WebPush {
vapid: vapidKeys,
},
null,
- 2
- )
+ 2,
+ ),
)
}
@@ -66,7 +66,7 @@ export class WebPush {
const index = subscriptions.findIndex(
(s) =>
s.destinationName === subscription.destinationName &&
- s.endpoint === subscription.endpoint
+ s.endpoint === subscription.endpoint,
)
if (index !== -1) {
subscriptions.splice(index, 1)
@@ -76,11 +76,11 @@ export class WebPush {
}
public async removeSubscription(
- subscription: Subscription
+ subscription: Subscription,
): Promise {
const subscriptions = this.getSubscriptions()
const index = subscriptions.findIndex(
- (s) => s.endpoint === subscription.endpoint
+ (s) => s.endpoint === subscription.endpoint,
)
if (index === -1) {
return false
@@ -107,7 +107,7 @@ export class WebPush {
public async sendNotification(
subscription: Subscription,
- payload: string
+ payload: string,
): Promise {
const logger = Logger.configure('WebPush.sendNotification')
const response = await webpush
@@ -129,12 +129,12 @@ export class WebPush {
public async sendNotifications(
destinationName: string,
title: string,
- body: string
+ body: string,
): Promise {
const logger = Logger.configure('WebPush.sendNotifications')
const subscriptions = this.getSubscriptions()
const destinationSubscriptions = subscriptions.filter(
- (s) => s.destinationName === destinationName
+ (s) => s.destinationName === destinationName,
)
if (destinationSubscriptions.length === 0) {
return
@@ -154,7 +154,7 @@ export class WebPush {
})
logger.info(
- `Sending notification to ${destinationSubscriptions.length} subscriptions...`
+ `Sending notification to ${destinationSubscriptions.length} subscriptions...`,
)
const promises = destinationSubscriptions.map((subscription) => {
return this.sendNotification(subscription, payload)
@@ -164,13 +164,13 @@ export class WebPush {
logger.info(
`Successfully sent notification to ${
results.filter((r) => r === 201).length
- } subscriptions!`
+ } subscriptions!`,
)
if (results.some((r) => r !== 201)) {
logger.warn(
`Failed to send notification to ${
results.filter((r) => r !== 201).length
- } subscriptions.`
+ } subscriptions.`,
)
}
}
diff --git a/src/web/api.ts b/src/web/api.ts
index acb122b0..5ddf0a48 100644
--- a/src/web/api.ts
+++ b/src/web/api.ts
@@ -23,7 +23,7 @@ export class ApiRouter extends BaseRouter {
.addHook('onRequest', fastify.basicAuth)
done()
},
- { prefix: '/api' }
+ { prefix: '/api' },
)
}
@@ -60,7 +60,7 @@ export class ApiRouter extends BaseRouter {
}
}
}>,
- reply: FastifyReply
+ reply: FastifyReply,
) {
const subscription = request.body
@@ -70,7 +70,7 @@ export class ApiRouter extends BaseRouter {
JSON.stringify({
title: '購読完了',
body: `購読が完了しました。${subscription.destinationName} の通知をお届けします。`,
- })
+ }),
)
await this.webPush.addSubscription(subscription)
@@ -105,7 +105,7 @@ export class ApiRouter extends BaseRouter {
}
}
}>,
- reply: FastifyReply
+ reply: FastifyReply,
) {
const subscription = request.body
const result = await this.webPush.removeSubscription(subscription)
diff --git a/src/web/base-router.ts b/src/web/base-router.ts
index 83f2d142..bad2dd2b 100644
--- a/src/web/base-router.ts
+++ b/src/web/base-router.ts
@@ -15,7 +15,7 @@ export abstract class BaseRouter {
fastify: FastifyInstance,
config: Configuration,
webPush: WebPush,
- version: string
+ version: string,
) {
this.fastify = fastify
this.config = config
diff --git a/src/web/view.ts b/src/web/view.ts
index f08f9ba0..d7ab9dc0 100644
--- a/src/web/view.ts
+++ b/src/web/view.ts
@@ -15,7 +15,7 @@ export class ViewRouter extends BaseRouter {
request: FastifyRequest<{
Params: { path: string }
}>,
- reply: FastifyReply
+ reply: FastifyReply,
) {
let path = request.url
if (path.includes('?')) {
@@ -56,7 +56,7 @@ export class ViewRouter extends BaseRouter {
fs
.readFileSync(`./public/${path}`)
.toString()
- .replaceAll('{{VERSION}}', this.version)
+ .replaceAll('{{VERSION}}', this.version),
)
return
}
diff --git a/yarn.lock b/yarn.lock
index f46b5fee..32279181 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -33,10 +33,10 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
-"@book000/node-utils@1.3.57":
- version "1.3.57"
- resolved "https://registry.yarnpkg.com/@book000/node-utils/-/node-utils-1.3.57.tgz#f3eb97cff0d079164e465bab44a6f6c936d9b623"
- integrity sha512-mddgMuzMPeGvDuIDNpJjYAV8z6w/+fzKoUmcS8c9XJQbMZq4qrT2DPYPaQtl20wVJKNf5Ngx3itQF5HZTecRwg==
+"@book000/node-utils@1.4.0":
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/@book000/node-utils/-/node-utils-1.4.0.tgz#9cde96264d17a0792eac606c4e4074669902846b"
+ integrity sha512-0Z9+tCWOtjFZLyV7QEQyI1fjq3oNm1s+tvo5fKJ2pr7dYWnr6Fzy3tWB9GelNtC+Q8ziMU9PbYPNXV0+NDxfEg==
dependencies:
axios "1.4.0"
cycle "1.0.3"
@@ -266,10 +266,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f"
integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==
-"@types/node@20.2.6":
- version "20.2.6"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-20.2.6.tgz#f8f4cdcf9bc74fffcb44a9e1e3f3586d583dac24"
- integrity sha512-GQBWUtGoefMEOx/vu+emHEHU5aw6JdDoEtZhoBrHFPZbA/YNRFfN996XbBASEWdvmLSLyv9FKYppYGyZjCaq/g==
+"@types/node@20.5.0":
+ version "20.5.0"
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-20.5.0.tgz#7fc8636d5f1aaa3b21e6245e97d56b7f56702313"
+ integrity sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==
"@types/node@^16.9.2":
version "16.18.11"
@@ -2657,10 +2657,10 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
-prettier@2.8.8:
- version "2.8.8"
- resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
- integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
+prettier@3.0.2:
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.2.tgz#78fcecd6d870551aa5547437cdae39d4701dca5b"
+ integrity sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==
process-warning@^2.0.0, process-warning@^2.2.0:
version "2.2.0"