mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #28541 from overleaf/td-notifications-app-ts
Change notifications app.js to TypeScript GitOrigin-RevId: cb6195e2e8c8cd89e1a954bfcb1911929440d6ca
This commit is contained in:
@@ -80,14 +80,14 @@ services:
|
|||||||
- ../services/history-v1/migrations:/overleaf/services/history-v1/migrations
|
- ../services/history-v1/migrations:/overleaf/services/history-v1/migrations
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
command: ["node", "--watch", "app.js"]
|
command: ["node", "--watch", "app.ts"]
|
||||||
environment:
|
environment:
|
||||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:9236:9229"
|
- "127.0.0.1:9236:9229"
|
||||||
volumes:
|
volumes:
|
||||||
- ../services/notifications/app:/overleaf/services/notifications/app
|
- ../services/notifications/app:/overleaf/services/notifications/app
|
||||||
- ../services/notifications/app.js:/overleaf/services/notifications/app.js
|
- ../services/notifications/app.ts:/overleaf/services/notifications/app.ts
|
||||||
- ../services/notifications/config:/overleaf/services/notifications/config
|
- ../services/notifications/config:/overleaf/services/notifications/config
|
||||||
|
|
||||||
project-history:
|
project-history:
|
||||||
|
|||||||
@@ -75,4 +75,4 @@ class RequestLogger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.monitor = monitor
|
module.exports = { monitor, RequestLogger }
|
||||||
|
|||||||
Generated
+11
@@ -19307,6 +19307,16 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/method-override": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/method-override/-/method-override-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-7XFHR6j7JljprBpzzRZatakUXm1kEGAM3PL/GSsGRHtDvOAKYCdmnXX/5YSl1eQrpJymGs9tRekSWEGaG+Ntjw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/express": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/mime": {
|
"node_modules/@types/mime": {
|
||||||
"version": "1.3.2",
|
"version": "1.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
|
||||||
@@ -52114,6 +52124,7 @@
|
|||||||
"zod-validation-error": "^4.0.1"
|
"zod-validation-error": "^4.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/method-override": "^3.0.0",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.6",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"mocha": "^11.1.0",
|
"mocha": "^11.1.0",
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ fi
|
|||||||
source /etc/overleaf/env.sh
|
source /etc/overleaf/env.sh
|
||||||
export LISTEN_ADDRESS=127.0.0.1
|
export LISTEN_ADDRESS=127.0.0.1
|
||||||
|
|
||||||
exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /overleaf/services/notifications/app.js >> /var/log/overleaf/notifications.log 2>&1
|
exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /overleaf/services/notifications/app.ts >> /var/log/overleaf/notifications.log 2>&1
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"include": [
|
"include": [
|
||||||
"api/**/*",
|
"api/**/*",
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"backup-deletion-app.mjs",
|
"backup-deletion-app.mjs",
|
||||||
"backup-verifier-app.mjs",
|
"backup-verifier-app.mjs",
|
||||||
|
|||||||
@@ -24,4 +24,5 @@ COPY services/notifications/ /overleaf/services/notifications/
|
|||||||
FROM app
|
FROM app
|
||||||
USER node
|
USER node
|
||||||
|
|
||||||
CMD ["node", "--expose-gc", "app.js"]
|
CMD ["node", "--expose-gc", "app.ts"]
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ import '@overleaf/metrics/initialize.js'
|
|||||||
import metrics from '@overleaf/metrics'
|
import metrics from '@overleaf/metrics'
|
||||||
import Settings from '@overleaf/settings'
|
import Settings from '@overleaf/settings'
|
||||||
import logger from '@overleaf/logger'
|
import logger from '@overleaf/logger'
|
||||||
import express from 'express'
|
import express, {
|
||||||
|
type Request,
|
||||||
|
type Response,
|
||||||
|
type ErrorRequestHandler,
|
||||||
|
type NextFunction,
|
||||||
|
} from 'express'
|
||||||
import methodOverride from 'method-override'
|
import methodOverride from 'method-override'
|
||||||
import { mongoClient } from './app/js/mongodb.js'
|
import { mongoClient } from './app/js/mongodb.js'
|
||||||
import NotificationsController from './app/js/NotificationsController.ts'
|
import NotificationsController from './app/js/NotificationsController.ts'
|
||||||
@@ -44,9 +49,12 @@ app.get('/health_check', HealthCheckController.check)
|
|||||||
|
|
||||||
app.get('*', (req, res) => res.sendStatus(404))
|
app.get('*', (req, res) => res.sendStatus(404))
|
||||||
|
|
||||||
app.use(handleApiError)
|
const handleApiError: ErrorRequestHandler = (
|
||||||
|
err: Error,
|
||||||
function handleApiError(err, req, res, next) {
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
) => {
|
||||||
req.logger.addFields({ err })
|
req.logger.addFields({ err })
|
||||||
if (err instanceof ParamsError) {
|
if (err instanceof ParamsError) {
|
||||||
req.logger.setLevel('warn')
|
req.logger.setLevel('warn')
|
||||||
@@ -60,6 +68,8 @@ function handleApiError(err, req, res, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.use(handleApiError)
|
||||||
|
|
||||||
const host = Settings.internal.notifications?.host || '127.0.0.1'
|
const host = Settings.internal.notifications?.host || '127.0.0.1'
|
||||||
const port = Settings.internal.notifications?.port || 3042
|
const port = Settings.internal.notifications?.port || 3042
|
||||||
try {
|
try {
|
||||||
@@ -8,4 +8,5 @@ notifications
|
|||||||
--public-repo=True
|
--public-repo=True
|
||||||
--test-acceptance-vitest=True
|
--test-acceptance-vitest=True
|
||||||
--test-unit-vitest=True
|
--test-unit-vitest=True
|
||||||
|
--ts-app=True
|
||||||
--tsconfig-extra-includes=vitest.config.unit.cjs,vitest.config.acceptance.cjs
|
--tsconfig-extra-includes=vitest.config.unit.cjs,vitest.config.acceptance.cjs
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
"name": "@overleaf/notifications",
|
"name": "@overleaf/notifications",
|
||||||
"description": "An API to handle user notifications",
|
"description": "An API to handle user notifications",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "app.js",
|
"main": "app.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node app.js",
|
"start": "node app.ts",
|
||||||
"test:acceptance:_run": "vitest --config ./vitest.config.acceptance.cjs",
|
"test:acceptance:_run": "vitest --config ./vitest.config.acceptance.cjs",
|
||||||
"test:acceptance": "npm run test:acceptance:_run",
|
"test:acceptance": "npm run test:acceptance:_run",
|
||||||
"test:unit:_run": "vitest --config ./vitest.config.unit.cjs",
|
"test:unit:_run": "vitest --config ./vitest.config.unit.cjs",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"format:fix": "prettier --write $PWD/'**/{*.*js,*.ts}'",
|
"format:fix": "prettier --write $PWD/'**/{*.*js,*.ts}'",
|
||||||
"lint:fix": "eslint --fix .",
|
"lint:fix": "eslint --fix .",
|
||||||
"types:check": "tsc --noEmit",
|
"types:check": "tsc --noEmit",
|
||||||
"nodemon": "node --watch app.js"
|
"nodemon": "node --watch app.ts"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
"zod-validation-error": "^4.0.1"
|
"zod-validation-error": "^4.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/method-override": "^3.0.0",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.6",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"mocha": "^11.1.0",
|
"mocha": "^11.1.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { beforeAll, describe, it, expect } from 'vitest'
|
import { beforeAll, describe, it, expect } from 'vitest'
|
||||||
import { fetchStringWithResponse } from '@overleaf/fetch-utils'
|
import { fetchStringWithResponse } from '@overleaf/fetch-utils'
|
||||||
import app from '../../../app.js'
|
import app from '../../../app.ts'
|
||||||
import logger from '@overleaf/logger'
|
import logger from '@overleaf/logger'
|
||||||
|
|
||||||
let runAppPromise: Promise<void> | null = null
|
let runAppPromise: Promise<void> | null = null
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import 'express'
|
||||||
|
import RequestLogger from '@overleaf/metrics'
|
||||||
|
|
||||||
|
// Add properties to Express's Request object that are defined in JS middleware
|
||||||
|
// or controllers and expected to be present in controllers.
|
||||||
|
declare global {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
namespace Express {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
interface Request {
|
||||||
|
logger: RequestLogger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"extends": "../../tsconfig.backend.json",
|
"extends": "../../tsconfig.backend.json",
|
||||||
"include": [
|
"include": [
|
||||||
"app.js",
|
"app.js",
|
||||||
|
"app.ts",
|
||||||
"app/js/**/*",
|
"app/js/**/*",
|
||||||
"benchmarks/**/*",
|
"benchmarks/**/*",
|
||||||
"config/**/*",
|
"config/**/*",
|
||||||
|
|||||||
Reference in New Issue
Block a user