mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-11-28 17:41:15 +00:00
Created logout route. Update eslint config file
This commit is contained in:
parent
eef8d9c5dc
commit
a2d4af45a3
71 changed files with 1038 additions and 316 deletions
|
@ -3,16 +3,15 @@
|
||||||
"es2021": true,
|
"es2021": true,
|
||||||
"node": true
|
"node": true
|
||||||
},
|
},
|
||||||
"extends": "standard-with-typescript",
|
"plugins": ["prettier"],
|
||||||
|
"extends": ["plugin:prettier/recommended"],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": "latest",
|
"ecmaVersion": "latest",
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"project": [
|
"project": ["./tsconfig.json"]
|
||||||
"./tsconfig.json"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-misused-promises": "off",
|
"@typescript-eslint/no-misused-promises": "off",
|
||||||
"@typescript-eslint/explicit-function-return-type": 1
|
"@typescript-eslint/explicit-function-return-type": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
672
package-lock.json
generated
672
package-lock.json
generated
|
@ -53,6 +53,7 @@
|
||||||
"eslint-config-standard-with-typescript": "^37.0.0",
|
"eslint-config-standard-with-typescript": "^37.0.0",
|
||||||
"eslint-plugin-import": "^2.28.0",
|
"eslint-plugin-import": "^2.28.0",
|
||||||
"eslint-plugin-n": "^16.0.1",
|
"eslint-plugin-n": "^16.0.1",
|
||||||
|
"eslint-plugin-prettier": "^5.0.0",
|
||||||
"eslint-plugin-promise": "^6.1.1",
|
"eslint-plugin-promise": "^6.1.1",
|
||||||
"nodemon": "^3.0.1",
|
"nodemon": "^3.0.1",
|
||||||
"pm2": "^4.2.3",
|
"pm2": "^4.2.3",
|
||||||
|
@ -1451,6 +1452,32 @@
|
||||||
"semver": "bin/semver"
|
"semver": "bin/semver"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@pkgr/utils": {
|
||||||
|
"version": "2.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.2.tgz",
|
||||||
|
"integrity": "sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"cross-spawn": "^7.0.3",
|
||||||
|
"fast-glob": "^3.3.0",
|
||||||
|
"is-glob": "^4.0.3",
|
||||||
|
"open": "^9.1.0",
|
||||||
|
"picocolors": "^1.0.0",
|
||||||
|
"tslib": "^2.6.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/unts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@pkgr/utils/node_modules/tslib": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@pm2/agent": {
|
"node_modules/@pm2/agent": {
|
||||||
"version": "1.0.8",
|
"version": "1.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-1.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-1.0.8.tgz",
|
||||||
|
@ -3507,6 +3534,15 @@
|
||||||
"node": ">= 10.0.0"
|
"node": ">= 10.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/big-integer": {
|
||||||
|
"version": "1.6.51",
|
||||||
|
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz",
|
||||||
|
"integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/bin-check": {
|
"node_modules/bin-check": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -3759,6 +3795,18 @@
|
||||||
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",
|
||||||
"integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA=="
|
"integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA=="
|
||||||
},
|
},
|
||||||
|
"node_modules/bplist-parser": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"big-integer": "^1.6.44"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 5.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -3810,6 +3858,21 @@
|
||||||
"semver": "^7.0.0"
|
"semver": "^7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/bundle-name": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"run-applescript": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/busboy": {
|
"node_modules/busboy": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
||||||
|
@ -4370,6 +4433,150 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/default-browser": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/default-browser/-/default-browser-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"bundle-name": "^3.0.0",
|
||||||
|
"default-browser-id": "^3.0.0",
|
||||||
|
"execa": "^7.1.1",
|
||||||
|
"titleize": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.16"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser-id": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"bplist-parser": "^0.2.0",
|
||||||
|
"untildify": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser/node_modules/execa": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"cross-spawn": "^7.0.3",
|
||||||
|
"get-stream": "^6.0.1",
|
||||||
|
"human-signals": "^4.3.0",
|
||||||
|
"is-stream": "^3.0.0",
|
||||||
|
"merge-stream": "^2.0.0",
|
||||||
|
"npm-run-path": "^5.1.0",
|
||||||
|
"onetime": "^6.0.0",
|
||||||
|
"signal-exit": "^3.0.7",
|
||||||
|
"strip-final-newline": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^14.18.0 || ^16.14.0 || >=18.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sindresorhus/execa?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser/node_modules/human-signals": {
|
||||||
|
"version": "4.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz",
|
||||||
|
"integrity": "sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.18.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser/node_modules/is-stream": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser/node_modules/mimic-fn": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser/node_modules/npm-run-path": {
|
||||||
|
"version": "5.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz",
|
||||||
|
"integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"path-key": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser/node_modules/onetime": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"mimic-fn": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser/node_modules/path-key": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/default-browser/node_modules/strip-final-newline": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/defer-to-connect": {
|
"node_modules/defer-to-connect": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -4378,6 +4585,18 @@
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/define-lazy-prop": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/define-properties": {
|
"node_modules/define-properties": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz",
|
||||||
|
@ -5097,6 +5316,35 @@
|
||||||
"eslint": ">=7.0.0"
|
"eslint": ">=7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-plugin-prettier": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-AgaZCVuYDXHUGxj/ZGu1u8H8CYgDY3iG6w5kUFw4AzMVXzB7VvbKgYR4nATIN+OvUrghMbiDLeimVjVY5ilq3w==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"prettier-linter-helpers": "^1.0.0",
|
||||||
|
"synckit": "^0.8.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^14.18.0 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/prettier"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/eslint": ">=8.0.0",
|
||||||
|
"eslint": ">=8.0.0",
|
||||||
|
"prettier": ">=3.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/eslint": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"eslint-config-prettier": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eslint-plugin-promise": {
|
"node_modules/eslint-plugin-promise": {
|
||||||
"version": "6.1.1",
|
"version": "6.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz",
|
||||||
|
@ -5410,15 +5658,22 @@
|
||||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/fast-diff": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/fast-fifo": {
|
"node_modules/fast-fifo": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.0.tgz",
|
||||||
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
||||||
},
|
},
|
||||||
"node_modules/fast-glob": {
|
"node_modules/fast-glob": {
|
||||||
"version": "3.2.12",
|
"version": "3.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz",
|
||||||
|
"integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodelib/fs.stat": "^2.0.2",
|
"@nodelib/fs.stat": "^2.0.2",
|
||||||
"@nodelib/fs.walk": "^1.2.3",
|
"@nodelib/fs.walk": "^1.2.3",
|
||||||
|
@ -6451,6 +6706,21 @@
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/is-docker": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"is-docker": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/is-extglob": {
|
"node_modules/is-extglob": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -6491,6 +6761,24 @@
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/is-inside-container": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"is-docker": "^3.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"is-inside-container": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.16"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/is-negative-zero": {
|
"node_modules/is-negative-zero": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
|
||||||
|
@ -6639,6 +6927,33 @@
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/is-wsl": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"is-docker": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-wsl/node_modules/is-docker": {
|
||||||
|
"version": "2.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
|
||||||
|
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"is-docker": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/isarray": {
|
"node_modules/isarray": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||||
|
@ -7507,6 +7822,24 @@
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/open": {
|
||||||
|
"version": "9.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/open/-/open-9.1.0.tgz",
|
||||||
|
"integrity": "sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"default-browser": "^4.0.0",
|
||||||
|
"define-lazy-prop": "^3.0.0",
|
||||||
|
"is-inside-container": "^1.0.0",
|
||||||
|
"is-wsl": "^2.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.16"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/optionator": {
|
"node_modules/optionator": {
|
||||||
"version": "0.9.3",
|
"version": "0.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz",
|
||||||
|
@ -7691,6 +8024,12 @@
|
||||||
"url": "https://github.com/sponsors/Borewit"
|
"url": "https://github.com/sponsors/Borewit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/picocolors": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -7931,6 +8270,18 @@
|
||||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/prettier-linter-helpers": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"fast-diff": "^1.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/prisma": {
|
"node_modules/prisma": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.0.0.tgz",
|
||||||
|
@ -8324,6 +8675,21 @@
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/run-applescript": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"execa": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/run-parallel": {
|
"node_modules/run-parallel": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"funding": [
|
"funding": [
|
||||||
|
@ -9091,6 +9457,28 @@
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/synckit": {
|
||||||
|
"version": "0.8.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.5.tgz",
|
||||||
|
"integrity": "sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@pkgr/utils": "^2.3.1",
|
||||||
|
"tslib": "^2.5.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^14.18.0 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/unts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/synckit/node_modules/tslib": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/tar": {
|
"node_modules/tar": {
|
||||||
"version": "6.1.15",
|
"version": "6.1.15",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
@ -9140,6 +9528,18 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/titleize": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/titleize/-/titleize-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/to-regex-range": {
|
"node_modules/to-regex-range": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -9568,6 +9968,15 @@
|
||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/untildify": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/uri-js": {
|
"node_modules/uri-js": {
|
||||||
"version": "4.4.1",
|
"version": "4.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||||
|
@ -11156,6 +11565,28 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@pkgr/utils": {
|
||||||
|
"version": "2.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.2.tgz",
|
||||||
|
"integrity": "sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"cross-spawn": "^7.0.3",
|
||||||
|
"fast-glob": "^3.3.0",
|
||||||
|
"is-glob": "^4.0.3",
|
||||||
|
"open": "^9.1.0",
|
||||||
|
"picocolors": "^1.0.0",
|
||||||
|
"tslib": "^2.6.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"@pm2/agent": {
|
"@pm2/agent": {
|
||||||
"version": "1.0.8",
|
"version": "1.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-1.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-1.0.8.tgz",
|
||||||
|
@ -12811,6 +13242,12 @@
|
||||||
"node-addon-api": "^5.0.0"
|
"node-addon-api": "^5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"big-integer": {
|
||||||
|
"version": "1.6.51",
|
||||||
|
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz",
|
||||||
|
"integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"bin-check": {
|
"bin-check": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -12980,6 +13417,15 @@
|
||||||
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",
|
||||||
"integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA=="
|
"integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA=="
|
||||||
},
|
},
|
||||||
|
"bplist-parser": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"big-integer": "^1.6.44"
|
||||||
|
}
|
||||||
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -13026,6 +13472,15 @@
|
||||||
"semver": "^7.0.0"
|
"semver": "^7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"bundle-name": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"run-applescript": "^5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"busboy": {
|
"busboy": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
||||||
|
@ -13426,10 +13881,105 @@
|
||||||
"version": "0.1.4",
|
"version": "0.1.4",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"default-browser": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/default-browser/-/default-browser-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"bundle-name": "^3.0.0",
|
||||||
|
"default-browser-id": "^3.0.0",
|
||||||
|
"execa": "^7.1.1",
|
||||||
|
"titleize": "^3.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"execa": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"cross-spawn": "^7.0.3",
|
||||||
|
"get-stream": "^6.0.1",
|
||||||
|
"human-signals": "^4.3.0",
|
||||||
|
"is-stream": "^3.0.0",
|
||||||
|
"merge-stream": "^2.0.0",
|
||||||
|
"npm-run-path": "^5.1.0",
|
||||||
|
"onetime": "^6.0.0",
|
||||||
|
"signal-exit": "^3.0.7",
|
||||||
|
"strip-final-newline": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"human-signals": {
|
||||||
|
"version": "4.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz",
|
||||||
|
"integrity": "sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"is-stream": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"mimic-fn": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"npm-run-path": {
|
||||||
|
"version": "5.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz",
|
||||||
|
"integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"path-key": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"onetime": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"mimic-fn": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"path-key": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"strip-final-newline": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default-browser-id": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"bplist-parser": "^0.2.0",
|
||||||
|
"untildify": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"defer-to-connect": {
|
"defer-to-connect": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"define-lazy-prop": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"define-properties": {
|
"define-properties": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz",
|
||||||
|
@ -13942,6 +14492,16 @@
|
||||||
"semver": "^7.5.3"
|
"semver": "^7.5.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"eslint-plugin-prettier": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-AgaZCVuYDXHUGxj/ZGu1u8H8CYgDY3iG6w5kUFw4AzMVXzB7VvbKgYR4nATIN+OvUrghMbiDLeimVjVY5ilq3w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"prettier-linter-helpers": "^1.0.0",
|
||||||
|
"synckit": "^0.8.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"eslint-plugin-promise": {
|
"eslint-plugin-promise": {
|
||||||
"version": "6.1.1",
|
"version": "6.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz",
|
||||||
|
@ -14150,13 +14710,21 @@
|
||||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"fast-diff": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"fast-fifo": {
|
"fast-fifo": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.0.tgz",
|
||||||
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
||||||
},
|
},
|
||||||
"fast-glob": {
|
"fast-glob": {
|
||||||
"version": "3.2.12",
|
"version": "3.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz",
|
||||||
|
"integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@nodelib/fs.stat": "^2.0.2",
|
"@nodelib/fs.stat": "^2.0.2",
|
||||||
|
@ -14835,6 +15403,12 @@
|
||||||
"has-tostringtag": "^1.0.0"
|
"has-tostringtag": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"is-docker": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"is-extglob": {
|
"is-extglob": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
@ -14857,6 +15431,15 @@
|
||||||
"is-extglob": "^2.1.1"
|
"is-extglob": "^2.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"is-inside-container": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"is-docker": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"is-negative-zero": {
|
"is-negative-zero": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
|
||||||
|
@ -14943,6 +15526,23 @@
|
||||||
"call-bind": "^1.0.2"
|
"call-bind": "^1.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"is-wsl": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"is-docker": "^2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"is-docker": {
|
||||||
|
"version": "2.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
|
||||||
|
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"isarray": {
|
"isarray": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||||
|
@ -15548,6 +16148,18 @@
|
||||||
"mimic-fn": "^2.1.0"
|
"mimic-fn": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"open": {
|
||||||
|
"version": "9.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/open/-/open-9.1.0.tgz",
|
||||||
|
"integrity": "sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"default-browser": "^4.0.0",
|
||||||
|
"define-lazy-prop": "^3.0.0",
|
||||||
|
"is-inside-container": "^1.0.0",
|
||||||
|
"is-wsl": "^2.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"optionator": {
|
"optionator": {
|
||||||
"version": "0.9.3",
|
"version": "0.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz",
|
||||||
|
@ -15665,6 +16277,12 @@
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"picocolors": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"picomatch": {
|
"picomatch": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
@ -15843,6 +16461,15 @@
|
||||||
"integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==",
|
"integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"prettier-linter-helpers": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"fast-diff": "^1.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.0.0.tgz",
|
||||||
|
@ -16099,6 +16726,15 @@
|
||||||
"glob": "^7.1.3"
|
"glob": "^7.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"run-applescript": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"execa": "^5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"run-parallel": {
|
"run-parallel": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -16604,6 +17240,24 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"synckit": {
|
||||||
|
"version": "0.8.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.5.tgz",
|
||||||
|
"integrity": "sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@pkgr/utils": "^2.3.1",
|
||||||
|
"tslib": "^2.5.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"tar": {
|
"tar": {
|
||||||
"version": "6.1.15",
|
"version": "6.1.15",
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -16649,6 +17303,12 @@
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"titleize": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/titleize/-/titleize-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"to-regex-range": {
|
"to-regex-range": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -16923,6 +17583,12 @@
|
||||||
"unpipe": {
|
"unpipe": {
|
||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
},
|
},
|
||||||
|
"untildify": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"uri-js": {
|
"uri-js": {
|
||||||
"version": "4.4.1",
|
"version": "4.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
"eslint-config-standard-with-typescript": "^37.0.0",
|
"eslint-config-standard-with-typescript": "^37.0.0",
|
||||||
"eslint-plugin-import": "^2.28.0",
|
"eslint-plugin-import": "^2.28.0",
|
||||||
"eslint-plugin-n": "^16.0.1",
|
"eslint-plugin-n": "^16.0.1",
|
||||||
|
"eslint-plugin-prettier": "^5.0.0",
|
||||||
"eslint-plugin-promise": "^6.1.1",
|
"eslint-plugin-promise": "^6.1.1",
|
||||||
"nodemon": "^3.0.1",
|
"nodemon": "^3.0.1",
|
||||||
"pm2": "^4.2.3",
|
"pm2": "^4.2.3",
|
||||||
|
|
14
src/app.ts
14
src/app.ts
|
@ -20,15 +20,17 @@ app.use(morganMiddleware)
|
||||||
app.use(limiter)
|
app.use(limiter)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(compression({ level: 9 }))
|
app.use(compression({ level: 9 }))
|
||||||
app.use(cors({
|
app.use(
|
||||||
credentials: true,
|
cors({
|
||||||
origin: '*', // TODO: Add client development (and production too) url
|
credentials: true,
|
||||||
optionsSuccessStatus: 200
|
origin: '*', // TODO: Add client development (and production too) url
|
||||||
}))
|
optionsSuccessStatus: 200,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
app.use((_req, res) => {
|
app.use((_req, res) => {
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
error: 'Endpoint not found'
|
error: 'Endpoint not found',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,19 @@ const redisHost = process.env.REDIS_HOST ?? '127.0.0.1'
|
||||||
const redisPassword = process.env.REDIS_PASSWORD ?? ''
|
const redisPassword = process.env.REDIS_PASSWORD ?? ''
|
||||||
|
|
||||||
const redisConfig: RedisClientOptions = {
|
const redisConfig: RedisClientOptions = {
|
||||||
url: `redis://:${redisPassword}@${redisHost}:${redisPort}/0`
|
url: `redis://:${redisPassword}@${redisHost}:${redisPort}/0`,
|
||||||
}
|
}
|
||||||
|
|
||||||
const redis = createClient(redisConfig)
|
const redis = createClient(redisConfig)
|
||||||
|
|
||||||
redis.connect().then(() => {
|
redis
|
||||||
logger.info('Successfully connected to Redis')
|
.connect()
|
||||||
}).catch((e: Error) => {
|
.then(() => {
|
||||||
logger.error(`Error while connecting to Redis: ${e.message}`)
|
logger.info('Successfully connected to Redis')
|
||||||
})
|
})
|
||||||
|
.catch((e: Error) => {
|
||||||
|
logger.error(`Error while connecting to Redis: ${e.message}`)
|
||||||
|
})
|
||||||
|
|
||||||
redis.on('error', async (e: Error) => {
|
redis.on('error', async (e: Error) => {
|
||||||
logger.error(`Error in Redis client: ${e.message}`)
|
logger.error(`Error in Redis client: ${e.message}`)
|
||||||
|
|
|
@ -8,16 +8,16 @@ if (process.env.NODE_ENV === 'development') {
|
||||||
s3 = new S3Client({
|
s3 = new S3Client({
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '',
|
accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '',
|
||||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? ''
|
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '',
|
||||||
},
|
},
|
||||||
endpoint: 'http://127.0.0.1:4566' // Uses localstack instead of aws, make sure to create the bucket first with public-read acl
|
endpoint: 'http://127.0.0.1:4566', // Uses localstack instead of aws, make sure to create the bucket first with public-read acl
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
s3 = new S3Client({
|
s3 = new S3Client({
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '',
|
accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '',
|
||||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? ''
|
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,21 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function commentCreateController (
|
async function commentCreateController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { content, postId } = req.body
|
const { content, postId } = req.body
|
||||||
const id = res.locals.user.id
|
const id = res.locals.user.id
|
||||||
|
|
||||||
if (postId === undefined) {
|
if (postId === undefined) {
|
||||||
badRequest(res, 'Expected post id'); return
|
badRequest(res, 'Expected post id')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content === undefined) {
|
if (content === undefined) {
|
||||||
badRequest(res, 'Expected comment content'); return
|
badRequest(res, 'Expected comment content')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await comment.create(postId, content, id)
|
const result = await comment.create(postId, content, id)
|
||||||
|
|
|
@ -3,15 +3,16 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function commentDeleteController (
|
async function commentDeleteController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { commentId } = req.body
|
const { commentId } = req.body
|
||||||
const id = res.locals.user.id
|
const id = res.locals.user.id
|
||||||
|
|
||||||
if (commentId === undefined) {
|
if (commentId === undefined) {
|
||||||
badRequest(res, 'Expected comment id'); return
|
badRequest(res, 'Expected comment id')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await comment.delete(commentId, id)
|
const result = await comment.delete(commentId, id)
|
||||||
|
|
|
@ -3,14 +3,15 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function commentFetchController (
|
async function commentFetchController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const commentId = req.query.id as string
|
const commentId = req.query.id as string
|
||||||
|
|
||||||
if (commentId === undefined) {
|
if (commentId === undefined) {
|
||||||
badRequest(res, 'Expected comment id'); return
|
badRequest(res, 'Expected comment id')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await comment.fetch(commentId)
|
const result = await comment.fetch(commentId)
|
||||||
|
|
|
@ -3,14 +3,15 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function commentFetchLikesController (
|
async function commentFetchLikesController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const commentId = req.query.id as string
|
const commentId = req.query.id as string
|
||||||
|
|
||||||
if (commentId === undefined) {
|
if (commentId === undefined) {
|
||||||
badRequest(res, 'Expected comment id'); return
|
badRequest(res, 'Expected comment id')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await comment.fetchLikes(commentId)
|
const result = await comment.fetchLikes(commentId)
|
||||||
|
|
|
@ -9,7 +9,7 @@ const comments = {
|
||||||
delete: commentDeleteController,
|
delete: commentDeleteController,
|
||||||
fetch: commentFetchController,
|
fetch: commentFetchController,
|
||||||
fetchLikes: commentFetchLikesController,
|
fetchLikes: commentFetchLikesController,
|
||||||
update: commentUpdateController
|
update: commentUpdateController,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export default comments
|
export default comments
|
||||||
|
|
|
@ -3,19 +3,21 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function commentUpdateController (
|
async function commentUpdateController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { commentId, content } = req.body
|
const { commentId, content } = req.body
|
||||||
const id = res.locals.user.id
|
const id = res.locals.user.id
|
||||||
|
|
||||||
if (commentId === undefined) {
|
if (commentId === undefined) {
|
||||||
badRequest(res, 'Expected comment content'); return
|
badRequest(res, 'Expected comment content')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content === undefined) {
|
if (content === undefined) {
|
||||||
badRequest(res, 'Expected content to update'); return
|
badRequest(res, 'Expected content to update')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await comment.update(content, id, commentId)
|
const result = await comment.update(content, id, commentId)
|
||||||
|
|
|
@ -3,15 +3,16 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function postCreateController (
|
async function postCreateController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { content } = req.body
|
const { content } = req.body
|
||||||
const id = res.locals.user.id
|
const id = res.locals.user.id
|
||||||
|
|
||||||
if (content === undefined) {
|
if (content === undefined) {
|
||||||
badRequest(res, 'Expected post content'); return
|
badRequest(res, 'Expected post content')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await post.create(content, id)
|
const result = await post.create(content, id)
|
||||||
|
|
|
@ -3,15 +3,16 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function postDeleteController (
|
async function postDeleteController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const userId = res.locals.user.id
|
const userId = res.locals.user.id
|
||||||
const postId = req.body.postId
|
const postId = req.body.postId
|
||||||
|
|
||||||
if (postId === undefined) {
|
if (postId === undefined) {
|
||||||
badRequest(res, 'Missing post id'); return
|
badRequest(res, 'Missing post id')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await post.delete(postId, userId)
|
const result = await post.delete(postId, userId)
|
||||||
|
|
|
@ -3,14 +3,15 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function postFetchInfoController (
|
async function postFetchInfoController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const id = req.query.id as string
|
const id = req.query.id as string
|
||||||
|
|
||||||
if (id === undefined) {
|
if (id === undefined) {
|
||||||
badRequest(res, 'Missing post id'); return
|
badRequest(res, 'Missing post id')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await post.fetch(id)
|
const result = await post.fetch(id)
|
||||||
|
|
|
@ -3,14 +3,15 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function postFetchLikesController (
|
async function postFetchLikesController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const id = req.query.id as string
|
const id = req.query.id as string
|
||||||
|
|
||||||
if (id === undefined) {
|
if (id === undefined) {
|
||||||
badRequest(res, 'Missing post id'); return
|
badRequest(res, 'Missing post id')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await post.fetchLikes(id)
|
const result = await post.fetchLikes(id)
|
||||||
|
|
|
@ -9,7 +9,7 @@ const post = {
|
||||||
delete: postDeleteController,
|
delete: postDeleteController,
|
||||||
fetch: postFetchInfoController,
|
fetch: postFetchInfoController,
|
||||||
fetchLikes: postFetchLikesController,
|
fetchLikes: postFetchLikesController,
|
||||||
update: postUpdateController
|
update: postUpdateController,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export default post
|
export default post
|
||||||
|
|
|
@ -2,9 +2,9 @@ import post from 'services/posts'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function postUpdateController (
|
async function postUpdateController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { postId, content } = req.body
|
const { postId, content } = req.body
|
||||||
const userId = res.locals.user.id
|
const userId = res.locals.user.id
|
||||||
|
|
|
@ -13,6 +13,7 @@ const usersRouter = Router()
|
||||||
usersRouter.get('/fetch-posts', user.fetchPosts)
|
usersRouter.get('/fetch-posts', user.fetchPosts)
|
||||||
usersRouter.get('/info', user.fetchInfo)
|
usersRouter.get('/info', user.fetchInfo)
|
||||||
usersRouter.get('/search', user.searchUser)
|
usersRouter.get('/search', user.searchUser)
|
||||||
|
usersRouter.get('/logout', authenticated, user.logout)
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
usersRouter.post('/auth', user.auth)
|
usersRouter.post('/auth', user.auth)
|
||||||
|
@ -27,7 +28,7 @@ usersRouter.put(
|
||||||
'/profile-picture/upload',
|
'/profile-picture/upload',
|
||||||
authenticated,
|
authenticated,
|
||||||
uploadFile,
|
uploadFile,
|
||||||
user.uploadPicture
|
user.uploadPicture,
|
||||||
)
|
)
|
||||||
usersRouter.put('/update-email', authenticated, user.updateEmail)
|
usersRouter.put('/update-email', authenticated, user.updateEmail)
|
||||||
usersRouter.put('/update-name', authenticated, user.updateName)
|
usersRouter.put('/update-name', authenticated, user.updateName)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
|
|
||||||
async function userAuthController (req: Request, res: Response): Promise<void> {
|
async function userAuthController(req: Request, res: Response): Promise<void> {
|
||||||
const { email, password } = req.body
|
const { email, password } = req.body
|
||||||
|
|
||||||
const result = await user.auth({ email, password })
|
const result = await user.auth({ email, password })
|
||||||
|
@ -10,10 +10,12 @@ async function userAuthController (req: Request, res: Response): Promise<void> {
|
||||||
if (result instanceof Error) {
|
if (result instanceof Error) {
|
||||||
badRequest(res, result.message)
|
badRequest(res, result.message)
|
||||||
} else {
|
} else {
|
||||||
res.cookie('token', result.token, {
|
res
|
||||||
httpOnly: true,
|
.cookie('token', result.token, {
|
||||||
secure: process.env.NODE_ENV === 'production'
|
httpOnly: true,
|
||||||
}).status(200)
|
secure: process.env.NODE_ENV === 'production',
|
||||||
|
})
|
||||||
|
.status(200)
|
||||||
.json({ message: 'Logged in successfully' })
|
.json({ message: 'Logged in successfully' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userDeleteController (
|
async function userDeleteController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const userId = res.locals.user.id
|
const userId = res.locals.user.id
|
||||||
const result = await user.delete(userId)
|
const result = await user.delete(userId)
|
||||||
|
|
|
@ -3,14 +3,15 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userFetchInfoController (
|
async function userFetchInfoController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const username = req.query.u as string
|
const username = req.query.u as string
|
||||||
|
|
||||||
if (username === undefined) {
|
if (username === undefined) {
|
||||||
badRequest(res, 'Missing username'); return
|
badRequest(res, 'Missing username')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await user.fetchInfo(username.toLowerCase())
|
const result = await user.fetchInfo(username.toLowerCase())
|
||||||
|
|
|
@ -3,14 +3,15 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userFetchPostsController (
|
async function userFetchPostsController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const username = req.query.u as string
|
const username = req.query.u as string
|
||||||
|
|
||||||
if (username === undefined) {
|
if (username === undefined) {
|
||||||
badRequest(res, 'Missing username'); return
|
badRequest(res, 'Missing username')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await user.fetchPosts(username)
|
const result = await user.fetchPosts(username)
|
||||||
|
|
|
@ -2,9 +2,9 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userFollowController (
|
async function userFollowController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const userId = res.locals.user.id
|
const userId = res.locals.user.id
|
||||||
const { userToFollow } = req.body
|
const { userToFollow } = req.body
|
||||||
|
|
|
@ -5,6 +5,7 @@ import userFetchInfoController from './fetch-info'
|
||||||
import userFetchPostsController from './fetch-posts'
|
import userFetchPostsController from './fetch-posts'
|
||||||
import userLikeCommentController from './like-comment'
|
import userLikeCommentController from './like-comment'
|
||||||
import userLikePostController from './like-post'
|
import userLikePostController from './like-post'
|
||||||
|
import userLogoutController from './logout'
|
||||||
import userSearchController from './search-user'
|
import userSearchController from './search-user'
|
||||||
import userSignupController from './signup'
|
import userSignupController from './signup'
|
||||||
import userUpdateEmailController from './update-email'
|
import userUpdateEmailController from './update-email'
|
||||||
|
@ -20,12 +21,13 @@ const user = {
|
||||||
follow: userFollowController,
|
follow: userFollowController,
|
||||||
likeComment: userLikeCommentController,
|
likeComment: userLikeCommentController,
|
||||||
likePost: userLikePostController,
|
likePost: userLikePostController,
|
||||||
|
logout: userLogoutController,
|
||||||
searchUser: userSearchController,
|
searchUser: userSearchController,
|
||||||
signup: userSignupController,
|
signup: userSignupController,
|
||||||
updateEmail: userUpdateEmailController,
|
updateEmail: userUpdateEmailController,
|
||||||
updateName: userUpdateNameController,
|
updateName: userUpdateNameController,
|
||||||
updatePassword: userUpdatePasswordController,
|
updatePassword: userUpdatePasswordController,
|
||||||
uploadPicture: userUploadPictureController
|
uploadPicture: userUploadPictureController,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export default user
|
export default user
|
||||||
|
|
|
@ -2,9 +2,9 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userLikeCommentController (
|
async function userLikeCommentController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const userId = res.locals.user.id
|
const userId = res.locals.user.id
|
||||||
const { commentId } = req.body
|
const { commentId } = req.body
|
||||||
|
|
|
@ -2,9 +2,9 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userLikePostController (
|
async function userLikePostController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const userId = res.locals.user.id
|
const userId = res.locals.user.id
|
||||||
const { postId } = req.body
|
const { postId } = req.body
|
||||||
|
|
14
src/controllers/users/logout.ts
Normal file
14
src/controllers/users/logout.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
async function userLogoutController(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
): Promise<void> {
|
||||||
|
// @ts-expect-error clearCookie interface does not exists in Response.
|
||||||
|
return res
|
||||||
|
.clearCookie('token')
|
||||||
|
.status(200)
|
||||||
|
.json({ message: 'Successfully logged out' })
|
||||||
|
}
|
||||||
|
|
||||||
|
export default userLogoutController
|
|
@ -2,14 +2,15 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
|
|
||||||
async function userSearchController (
|
async function userSearchController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const username = req.query.u as string
|
const username = req.query.u as string
|
||||||
|
|
||||||
if (username === undefined) {
|
if (username === undefined) {
|
||||||
badRequest(res, 'Missing username'); return
|
badRequest(res, 'Missing username')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await user.searchUser(username)
|
const result = await user.searchUser(username)
|
||||||
|
|
|
@ -2,9 +2,9 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userSignupController (
|
async function userSignupController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { username, email, password } = req.body
|
const { username, email, password } = req.body
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userUpdateEmailController (
|
async function userUpdateEmailController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { email } = req.body
|
const { email } = req.body
|
||||||
const id = res.locals.user.id
|
const id = res.locals.user.id
|
||||||
|
|
|
@ -2,9 +2,9 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userUpdateNameController (
|
async function userUpdateNameController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { displayName, username } = req.body
|
const { displayName, username } = req.body
|
||||||
const id = res.locals.user.id
|
const id = res.locals.user.id
|
||||||
|
|
|
@ -2,9 +2,9 @@ import user from 'services/users'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userUpdatePasswordController (
|
async function userUpdatePasswordController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { currentPassword, newPassword } = req.body
|
const { currentPassword, newPassword } = req.body
|
||||||
const id = res.locals.user.id
|
const id = res.locals.user.id
|
||||||
|
|
|
@ -4,12 +4,13 @@ import type { Request, Response } from 'express'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
import handleResponse from 'helpers/handle-response'
|
import handleResponse from 'helpers/handle-response'
|
||||||
|
|
||||||
async function userUploadPictureController (
|
async function userUploadPictureController(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (req.file === undefined) {
|
if (req.file === undefined) {
|
||||||
badRequest(res, 'Expected a JPG or PNG file'); return
|
badRequest(res, 'Expected a JPG or PNG file')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const userId = res.locals.user.id
|
const userId = res.locals.user.id
|
||||||
|
@ -17,7 +18,9 @@ async function userUploadPictureController (
|
||||||
let url: string
|
let url: string
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
url = `http://${process.env.AWS_BUCKET ?? ''}.s3.localhost.localstack.cloud:4566/${req.file.key}`
|
url = `http://${
|
||||||
|
process.env.AWS_BUCKET ?? ''
|
||||||
|
}.s3.localhost.localstack.cloud:4566/${req.file.key}`
|
||||||
} else {
|
} else {
|
||||||
url = req.file.location
|
url = req.file.location
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,16 @@ import sharp from 'sharp'
|
||||||
import s3 from 'clients/s3-client'
|
import s3 from 'clients/s3-client'
|
||||||
import { GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3'
|
import { GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3'
|
||||||
|
|
||||||
export default async function compressImage (
|
export default async function compressImage(
|
||||||
imageName: string,
|
imageName: string,
|
||||||
isProfilePicture: string
|
isProfilePicture: string,
|
||||||
): Promise<Error | Record<never, never>> {
|
): Promise<Error | Record<never, never>> {
|
||||||
// Get file from s3
|
// Get file from s3
|
||||||
const { Body } = await s3.send(
|
const { Body } = await s3.send(
|
||||||
new GetObjectCommand({
|
new GetObjectCommand({
|
||||||
Bucket: process.env.AWS_BUCKET ?? '',
|
Bucket: process.env.AWS_BUCKET ?? '',
|
||||||
Key: imageName
|
Key: imageName,
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
const imageBuffer = await Body?.transformToByteArray()
|
const imageBuffer = await Body?.transformToByteArray()
|
||||||
|
@ -19,7 +19,7 @@ export default async function compressImage (
|
||||||
const compressedImageBuffer = await sharp(imageBuffer)
|
const compressedImageBuffer = await sharp(imageBuffer)
|
||||||
.resize(
|
.resize(
|
||||||
isProfilePicture === 'true' ? 200 : undefined,
|
isProfilePicture === 'true' ? 200 : undefined,
|
||||||
isProfilePicture === 'true' ? 200 : undefined
|
isProfilePicture === 'true' ? 200 : undefined,
|
||||||
)
|
)
|
||||||
.jpeg({ quality: 65 })
|
.jpeg({ quality: 65 })
|
||||||
.toBuffer()
|
.toBuffer()
|
||||||
|
@ -30,7 +30,7 @@ export default async function compressImage (
|
||||||
Key: imageName,
|
Key: imageName,
|
||||||
Body: compressedImageBuffer,
|
Body: compressedImageBuffer,
|
||||||
ContentType: 'image/jpeg',
|
ContentType: 'image/jpeg',
|
||||||
ContentDisposition: 'inline'
|
ContentDisposition: 'inline',
|
||||||
}
|
}
|
||||||
|
|
||||||
const { ETag } = await s3.send(new PutObjectCommand(params))
|
const { ETag } = await s3.send(new PutObjectCommand(params))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { type Response } from 'express'
|
import { type Response } from 'express'
|
||||||
import { badRequest } from './http-errors'
|
import { badRequest } from './http-errors'
|
||||||
|
|
||||||
export default function handleResponse (res: Response, result: any): void {
|
export default function handleResponse(res: Response, result: any): void {
|
||||||
if (result instanceof Error) {
|
if (result instanceof Error) {
|
||||||
badRequest(res, result.message)
|
badRequest(res, result.message)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { type Response } from 'express'
|
||||||
const sendErrorResponse = (
|
const sendErrorResponse = (
|
||||||
res: Response,
|
res: Response,
|
||||||
status: number,
|
status: number,
|
||||||
message: string
|
message: string,
|
||||||
): void => {
|
): void => {
|
||||||
res.status(status).json({ error: message })
|
res.status(status).json({ error: message })
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export const forbidden = (res: Response, message = 'Forbidden'): void => {
|
||||||
|
|
||||||
export const internalServerError = (
|
export const internalServerError = (
|
||||||
res: Response,
|
res: Response,
|
||||||
message = 'Internal Server Error'
|
message = 'Internal Server Error',
|
||||||
): void => {
|
): void => {
|
||||||
sendErrorResponse(res, 500, message)
|
sendErrorResponse(res, 500, message)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ const levels = {
|
||||||
warn: 1,
|
warn: 1,
|
||||||
info: 2,
|
info: 2,
|
||||||
http: 3,
|
http: 3,
|
||||||
debug: 4
|
debug: 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
const level = (): string => {
|
const level = (): string => {
|
||||||
|
@ -20,7 +20,7 @@ const colors = {
|
||||||
warn: 'yellow',
|
warn: 'yellow',
|
||||||
info: 'green',
|
info: 'green',
|
||||||
http: 'magenta',
|
http: 'magenta',
|
||||||
debug: 'white'
|
debug: 'white',
|
||||||
}
|
}
|
||||||
|
|
||||||
winston.addColors(colors)
|
winston.addColors(colors)
|
||||||
|
@ -30,23 +30,23 @@ const format = winston.format.combine(
|
||||||
winston.format.colorize({ all: true }),
|
winston.format.colorize({ all: true }),
|
||||||
winston.format.printf(
|
winston.format.printf(
|
||||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||||
(info) => `${info.timestamp} ${info.level}: ${info.message}`
|
info => `${info.timestamp} ${info.level}: ${info.message}`,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
const transports = [
|
const transports = [
|
||||||
new winston.transports.Console(),
|
new winston.transports.Console(),
|
||||||
new winston.transports.File({
|
new winston.transports.File({
|
||||||
filename: 'logs/error.log',
|
filename: 'logs/error.log',
|
||||||
level: 'error'
|
level: 'error',
|
||||||
})
|
}),
|
||||||
]
|
]
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: level(),
|
level: level(),
|
||||||
levels,
|
levels,
|
||||||
format,
|
format,
|
||||||
transports
|
transports,
|
||||||
})
|
})
|
||||||
|
|
||||||
export default logger
|
export default logger
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { type NotificationType } from '@prisma/client'
|
import { type NotificationType } from '@prisma/client'
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
export async function createNotification (
|
export async function createNotification(
|
||||||
fromUserId: string,
|
fromUserId: string,
|
||||||
toUserId: string,
|
toUserId: string,
|
||||||
content: string,
|
content: string,
|
||||||
type: NotificationType
|
type: NotificationType,
|
||||||
): Promise<Record<never, never> | Error> {
|
): Promise<Record<never, never> | Error> {
|
||||||
try {
|
try {
|
||||||
await prisma.notifications.create({
|
await prisma.notifications.create({
|
||||||
|
@ -13,7 +13,7 @@ export async function createNotification (
|
||||||
type,
|
type,
|
||||||
fromUserId,
|
fromUserId,
|
||||||
toUserId,
|
toUserId,
|
||||||
content
|
content,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
fromUser: {
|
fromUser: {
|
||||||
|
@ -21,10 +21,10 @@ export async function createNotification (
|
||||||
id: true,
|
id: true,
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
profileImage: true
|
profileImage: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
@ -32,12 +32,14 @@ export async function createNotification (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function countNotifications (toUserId: string): Promise<number | Error> {
|
export async function countNotifications(
|
||||||
|
toUserId: string,
|
||||||
|
): Promise<number | Error> {
|
||||||
try {
|
try {
|
||||||
const count = await prisma.notifications.count({
|
const count = await prisma.notifications.count({
|
||||||
where: {
|
where: {
|
||||||
toUserId
|
toUserId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return count
|
return count
|
||||||
|
|
|
@ -4,32 +4,38 @@ import type { Response, Request, NextFunction } from 'express'
|
||||||
import { unauthorized } from 'helpers/http-errors'
|
import { unauthorized } from 'helpers/http-errors'
|
||||||
import type jwtPayload from 'interfaces/jwt'
|
import type jwtPayload from 'interfaces/jwt'
|
||||||
|
|
||||||
async function authenticated (
|
async function authenticated(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
next: NextFunction
|
next: NextFunction,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const token = req.cookies.token
|
const token = req.cookies.token
|
||||||
|
|
||||||
if (token === undefined) {
|
if (token === undefined) {
|
||||||
unauthorized(res, 'Missing token'); return
|
unauthorized(res, 'Missing token')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id } = verify(token, process.env.JWT_ACCESS_SECRET ?? '') as jwtPayload
|
const { id } = verify(
|
||||||
|
token,
|
||||||
|
process.env.JWT_ACCESS_SECRET ?? '',
|
||||||
|
) as jwtPayload
|
||||||
|
|
||||||
if (id === undefined) {
|
if (id === undefined) {
|
||||||
unauthorized(res, 'Invalid token'); return
|
unauthorized(res, 'Invalid token')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id
|
id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (user === undefined) {
|
if (user === undefined) {
|
||||||
unauthorized(res, 'User does not exists'); return
|
unauthorized(res, 'User does not exists')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
res.locals.user = user
|
res.locals.user = user
|
||||||
|
|
|
@ -2,12 +2,11 @@ import morgan, { type StreamOptions } from 'morgan'
|
||||||
import logger from 'helpers/logger'
|
import logger from 'helpers/logger'
|
||||||
|
|
||||||
const stream: StreamOptions = {
|
const stream: StreamOptions = {
|
||||||
write: (message) => logger.http(message)
|
write: message => logger.http(message),
|
||||||
}
|
}
|
||||||
|
|
||||||
const morganMiddleware = morgan(
|
const morganMiddleware = morgan(':method :url :status - :response-time ms', {
|
||||||
':method :url :status - :response-time ms',
|
stream,
|
||||||
{ stream }
|
})
|
||||||
)
|
|
||||||
|
|
||||||
export default morganMiddleware
|
export default morganMiddleware
|
||||||
|
|
|
@ -20,8 +20,8 @@ const limiter = rateLimit({
|
||||||
|
|
||||||
// Store configuration
|
// Store configuration
|
||||||
store: new RedisStore({
|
store: new RedisStore({
|
||||||
sendCommand: async (...args: string[]) => await redis.sendCommand(args)
|
sendCommand: async (...args: string[]) => await redis.sendCommand(args),
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
export default limiter
|
export default limiter
|
||||||
|
|
|
@ -4,23 +4,23 @@ import multerConfig from 'config/multer'
|
||||||
import compressImage from 'helpers/compress-image'
|
import compressImage from 'helpers/compress-image'
|
||||||
import { badRequest } from 'helpers/http-errors'
|
import { badRequest } from 'helpers/http-errors'
|
||||||
|
|
||||||
function uploadImage (req: Request, res: Response, next: NextFunction): void {
|
function uploadImage(req: Request, res: Response, next: NextFunction): void {
|
||||||
const upload = multer(multerConfig).single('image')
|
const upload = multer(multerConfig).single('image')
|
||||||
|
|
||||||
upload(req, res, async (cb: multer.MulterError | Error | any) => {
|
upload(req, res, async (cb: multer.MulterError | Error | any) => {
|
||||||
if (req.res?.locals.user == null) {
|
if (req.res?.locals.user == null) {
|
||||||
badRequest(
|
badRequest(res, 'You must be logged in to upload a profile picture')
|
||||||
res,
|
return
|
||||||
'You must be logged in to upload a profile picture'
|
|
||||||
); return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb instanceof multer.MulterError || cb instanceof Error) {
|
if (cb instanceof multer.MulterError || cb instanceof Error) {
|
||||||
badRequest(res, cb.message); return
|
badRequest(res, cb.message)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.file === undefined) {
|
if (req.file === undefined) {
|
||||||
badRequest(res, 'Expected file'); return
|
badRequest(res, 'Expected file')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await compressImage(req.file?.key, req.body.isProfilePicture)
|
await compressImage(req.file?.key, req.body.isProfilePicture)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function commentCreateService (
|
async function commentCreateService(
|
||||||
postId: string,
|
postId: string,
|
||||||
content: string,
|
content: string,
|
||||||
authorId: string
|
authorId: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const post = await prisma.post.findFirst({
|
const post = await prisma.post.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: postId
|
id: postId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (post === null) {
|
if (post === null) {
|
||||||
|
@ -17,8 +17,8 @@ async function commentCreateService (
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: authorId
|
id: authorId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
|
@ -29,8 +29,8 @@ async function commentCreateService (
|
||||||
data: {
|
data: {
|
||||||
content,
|
content,
|
||||||
postId,
|
postId,
|
||||||
userId: authorId
|
userId: authorId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return comment
|
return comment
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function commentDeleteService (
|
async function commentDeleteService(
|
||||||
commentId: string,
|
commentId: string,
|
||||||
authorId: string
|
authorId: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: authorId
|
id: authorId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
|
@ -17,8 +17,8 @@ async function commentDeleteService (
|
||||||
const comment = await prisma.comments.findFirst({
|
const comment = await prisma.comments.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: commentId,
|
id: commentId,
|
||||||
userId: user.id
|
userId: user.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (comment === null) {
|
if (comment === null) {
|
||||||
|
@ -28,8 +28,8 @@ async function commentDeleteService (
|
||||||
await prisma.comments.deleteMany({
|
await prisma.comments.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
id: comment.id,
|
id: comment.id,
|
||||||
userId: user.id
|
userId: user.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function commentFetchService (commentId: string): Promise<Record<string, unknown> | Error> {
|
async function commentFetchService(
|
||||||
|
commentId: string,
|
||||||
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const comment = await prisma.comments.findFirst({
|
const comment = await prisma.comments.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: commentId
|
id: commentId,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
@ -15,10 +17,10 @@ async function commentFetchService (commentId: string): Promise<Record<string, u
|
||||||
id: true,
|
id: true,
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
profileImage: true
|
profileImage: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (comment === null) {
|
if (comment === null) {
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function commentFetchLikesService (id: string): Promise<unknown | Error> {
|
async function commentFetchLikesService(id: string): Promise<unknown | Error> {
|
||||||
const post = await prisma.commentLike.findMany({
|
const post = await prisma.commentLike.findMany({
|
||||||
where: {
|
where: {
|
||||||
commentId: id
|
commentId: id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
user: {
|
user: {
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
profileImage: true
|
profileImage: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (post === null) {
|
if (post === null) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ const comment = {
|
||||||
delete: commentDeleteService,
|
delete: commentDeleteService,
|
||||||
fetch: commentFetchService,
|
fetch: commentFetchService,
|
||||||
fetchLikes: commentFetchLikesService,
|
fetchLikes: commentFetchLikesService,
|
||||||
update: commentUpdateService
|
update: commentUpdateService,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export default comment
|
export default comment
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function commentUpdateService (
|
async function commentUpdateService(
|
||||||
content: string,
|
content: string,
|
||||||
authorId: string,
|
authorId: string,
|
||||||
commentId: string
|
commentId: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const comment = await prisma.comments.findFirst({
|
const comment = await prisma.comments.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: commentId,
|
id: commentId,
|
||||||
userId: authorId
|
userId: authorId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (comment === null) {
|
if (comment === null) {
|
||||||
|
@ -19,10 +19,10 @@ async function commentUpdateService (
|
||||||
const updatedComment = await prisma.comments.update({
|
const updatedComment = await prisma.comments.update({
|
||||||
where: {
|
where: {
|
||||||
id: comment.id,
|
id: comment.id,
|
||||||
userId: authorId
|
userId: authorId,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
content
|
content,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
@ -33,10 +33,10 @@ async function commentUpdateService (
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
profileImage: true
|
profileImage: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return updatedComment
|
return updatedComment
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function postCreateService (
|
async function postCreateService(
|
||||||
content: string,
|
content: string,
|
||||||
authorId: string
|
authorId: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const user = await prisma.user.findFirst({ where: { id: authorId } })
|
const user = await prisma.user.findFirst({ where: { id: authorId } })
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ async function postCreateService (
|
||||||
const post = await prisma.post.create({
|
const post = await prisma.post.create({
|
||||||
data: {
|
data: {
|
||||||
content,
|
content,
|
||||||
authorId
|
authorId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return post
|
return post
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function postDeleteService (
|
async function postDeleteService(
|
||||||
postId: string,
|
postId: string,
|
||||||
userId: string
|
userId: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const post = await prisma.post.findFirst({ where: { id: postId } })
|
const post = await prisma.post.findFirst({ where: { id: postId } })
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ async function postDeleteService (
|
||||||
|
|
||||||
await prisma.post.deleteMany({
|
await prisma.post.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
id: postId
|
id: postId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function postFetchInfoService (id: string): Promise<Record<string, unknown> | Error> {
|
async function postFetchInfoService(
|
||||||
|
id: string,
|
||||||
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const post = await prisma.post.findFirst({
|
const post = await prisma.post.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id
|
id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
@ -14,10 +16,10 @@ async function postFetchInfoService (id: string): Promise<Record<string, unknown
|
||||||
author: {
|
author: {
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true
|
username: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (post === null) {
|
if (post === null) {
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function postFetchLikesService (id: string): Promise<unknown | Error> {
|
async function postFetchLikesService(id: string): Promise<unknown | Error> {
|
||||||
const post = await prisma.postLike.findMany({
|
const post = await prisma.postLike.findMany({
|
||||||
where: {
|
where: {
|
||||||
postId: id
|
postId: id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
user: {
|
user: {
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
profileImage: true
|
profileImage: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (post === null) {
|
if (post === null) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ const post = {
|
||||||
delete: postDeleteService,
|
delete: postDeleteService,
|
||||||
fetch: postFetchInfoService,
|
fetch: postFetchInfoService,
|
||||||
fetchLikes: postFetchLikesService,
|
fetchLikes: postFetchLikesService,
|
||||||
update: postUpdateService
|
update: postUpdateService,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export default post
|
export default post
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function postUpdateService (
|
async function postUpdateService(
|
||||||
postId: string,
|
postId: string,
|
||||||
content: string,
|
content: string,
|
||||||
userId: string
|
userId: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const post = await prisma.post.findFirst({ where: { id: postId } })
|
const post = await prisma.post.findFirst({ where: { id: postId } })
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ async function postUpdateService (
|
||||||
|
|
||||||
const updatedPost = await prisma.post.update({
|
const updatedPost = await prisma.post.update({
|
||||||
where: {
|
where: {
|
||||||
id: postId
|
id: postId,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
content
|
content,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
@ -38,10 +38,10 @@ async function postUpdateService (
|
||||||
author: {
|
author: {
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true
|
username: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return updatedPost
|
return updatedPost
|
||||||
|
|
|
@ -3,14 +3,14 @@ import jsonwebtoken from 'jsonwebtoken'
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
import type User from 'interfaces/user'
|
import type User from 'interfaces/user'
|
||||||
|
|
||||||
async function userAuthService ({
|
async function userAuthService({
|
||||||
email,
|
email,
|
||||||
password
|
password,
|
||||||
}: User): Promise<Record<string, unknown> | Error> {
|
}: User): Promise<Record<string, unknown> | Error> {
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
email
|
email,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
@ -23,7 +23,7 @@ async function userAuthService ({
|
||||||
|
|
||||||
const validPassword = await bcrypt.compare(
|
const validPassword = await bcrypt.compare(
|
||||||
password.replace(/ /g, ''),
|
password.replace(/ /g, ''),
|
||||||
user.password
|
user.password,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!validPassword) {
|
if (!validPassword) {
|
||||||
|
@ -35,11 +35,11 @@ async function userAuthService ({
|
||||||
const bearer = jsonwebtoken.sign(
|
const bearer = jsonwebtoken.sign(
|
||||||
{ id },
|
{ id },
|
||||||
process.env.JWT_ACCESS_SECRET ?? '',
|
process.env.JWT_ACCESS_SECRET ?? '',
|
||||||
{ expiresIn: '1d' }
|
{ expiresIn: '1d' },
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
token: bearer
|
token: bearer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userDeleteService (userId: string): Promise<Record<string, unknown> | Error> {
|
async function userDeleteService(
|
||||||
|
userId: string,
|
||||||
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const user = await prisma.user.findFirst({ where: { id: userId } })
|
const user = await prisma.user.findFirst({ where: { id: userId } })
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
|
@ -13,8 +15,8 @@ async function userDeleteService (userId: string): Promise<Record<string, unknow
|
||||||
|
|
||||||
await prisma.user.deleteMany({
|
await prisma.user.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
id: userId
|
id: userId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userFetchInfoService (username: string): Promise<Record<string, unknown> | Error> {
|
async function userFetchInfoService(
|
||||||
|
username: string,
|
||||||
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
username
|
username,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
profileImage: true,
|
profileImage: true,
|
||||||
|
@ -15,15 +17,15 @@ async function userFetchInfoService (username: string): Promise<Record<string, u
|
||||||
id: true,
|
id: true,
|
||||||
content: true,
|
content: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
updatedAt: true
|
updatedAt: true,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
likedPosts: {
|
likedPosts: {
|
||||||
select: {
|
select: {
|
||||||
postId: true
|
postId: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userFetchPostsService (
|
async function userFetchPostsService(
|
||||||
username: string
|
username: string,
|
||||||
): Promise<unknown | Error> {
|
): Promise<unknown | Error> {
|
||||||
const posts = await prisma.post.findMany({
|
const posts = await prisma.post.findMany({
|
||||||
where: {
|
where: {
|
||||||
author: {
|
author: {
|
||||||
username
|
username,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
_count: true,
|
_count: true,
|
||||||
id: true,
|
id: true,
|
||||||
content: true,
|
content: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
updatedAt: true
|
updatedAt: true,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return posts
|
return posts
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userFollowService (
|
async function userFollowService(
|
||||||
userId: string,
|
userId: string,
|
||||||
followingUsername: string
|
followingUsername: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
if (userId === undefined || followingUsername === undefined) {
|
if (userId === undefined || followingUsername === undefined) {
|
||||||
return new Error('Missing fields')
|
return new Error('Missing fields')
|
||||||
|
@ -10,8 +10,8 @@ async function userFollowService (
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
username: followingUsername
|
username: followingUsername,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
|
@ -20,8 +20,8 @@ async function userFollowService (
|
||||||
|
|
||||||
const userToFollow = await prisma.user.findFirst({
|
const userToFollow = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: userId
|
id: userId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (userToFollow === null) {
|
if (userToFollow === null) {
|
||||||
|
@ -31,16 +31,16 @@ async function userFollowService (
|
||||||
const alreadyFollow = await prisma.follows.findFirst({
|
const alreadyFollow = await prisma.follows.findFirst({
|
||||||
where: {
|
where: {
|
||||||
followerId: user.id,
|
followerId: user.id,
|
||||||
followingId: userToFollow.id
|
followingId: userToFollow.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (alreadyFollow !== null) {
|
if (alreadyFollow !== null) {
|
||||||
await prisma.follows.deleteMany({
|
await prisma.follows.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
followerId: user.id,
|
followerId: user.id,
|
||||||
followingId: userToFollow.id
|
followingId: userToFollow.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ async function userFollowService (
|
||||||
const follow = await prisma.follows.create({
|
const follow = await prisma.follows.create({
|
||||||
data: {
|
data: {
|
||||||
followerId: user.id,
|
followerId: user.id,
|
||||||
followingId: userToFollow.id
|
followingId: userToFollow.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return follow
|
return follow
|
||||||
|
|
|
@ -25,7 +25,7 @@ const user = {
|
||||||
updateEmail: userUpdateEmailService,
|
updateEmail: userUpdateEmailService,
|
||||||
updateName: userUpdateNameService,
|
updateName: userUpdateNameService,
|
||||||
updatePassword: userUpdatePasswordService,
|
updatePassword: userUpdatePasswordService,
|
||||||
uploadPicture: userUploadPictureService
|
uploadPicture: userUploadPictureService,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export default user
|
export default user
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userLikeCommentService (
|
async function userLikeCommentService(
|
||||||
commentId: string,
|
commentId: string,
|
||||||
userId: string
|
userId: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
if (commentId === undefined || userId === undefined) {
|
if (commentId === undefined || userId === undefined) {
|
||||||
return new Error('Missing fields')
|
return new Error('Missing fields')
|
||||||
|
@ -10,8 +10,8 @@ async function userLikeCommentService (
|
||||||
|
|
||||||
const comment = await prisma.comments.findFirst({
|
const comment = await prisma.comments.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: commentId
|
id: commentId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (comment === null) {
|
if (comment === null) {
|
||||||
|
@ -20,8 +20,8 @@ async function userLikeCommentService (
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: userId
|
id: userId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
|
@ -31,16 +31,16 @@ async function userLikeCommentService (
|
||||||
const alreadyLiked = await prisma.commentLike.findFirst({
|
const alreadyLiked = await prisma.commentLike.findFirst({
|
||||||
where: {
|
where: {
|
||||||
commentId: comment.id,
|
commentId: comment.id,
|
||||||
userId: user.id
|
userId: user.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (alreadyLiked !== null) {
|
if (alreadyLiked !== null) {
|
||||||
await prisma.commentLike.deleteMany({
|
await prisma.commentLike.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
commentId: comment.id,
|
commentId: comment.id,
|
||||||
userId: user.id
|
userId: user.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ async function userLikeCommentService (
|
||||||
const like = await prisma.commentLike.create({
|
const like = await prisma.commentLike.create({
|
||||||
data: {
|
data: {
|
||||||
commentId: comment.id,
|
commentId: comment.id,
|
||||||
userId: user.id
|
userId: user.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return like
|
return like
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userLikePostService (
|
async function userLikePostService(
|
||||||
postId: string,
|
postId: string,
|
||||||
userId: string
|
userId: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
if (postId === undefined || userId === undefined) {
|
if (postId === undefined || userId === undefined) {
|
||||||
return new Error('Missing fields')
|
return new Error('Missing fields')
|
||||||
|
@ -10,8 +10,8 @@ async function userLikePostService (
|
||||||
|
|
||||||
const post = await prisma.post.findFirst({
|
const post = await prisma.post.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: postId
|
id: postId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (post === null) {
|
if (post === null) {
|
||||||
|
@ -20,8 +20,8 @@ async function userLikePostService (
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id: userId
|
id: userId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
|
@ -31,16 +31,16 @@ async function userLikePostService (
|
||||||
const alreadyLiked = await prisma.postLike.findFirst({
|
const alreadyLiked = await prisma.postLike.findFirst({
|
||||||
where: {
|
where: {
|
||||||
postId: post.id,
|
postId: post.id,
|
||||||
userId: user.id
|
userId: user.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (alreadyLiked !== null) {
|
if (alreadyLiked !== null) {
|
||||||
await prisma.postLike.deleteMany({
|
await prisma.postLike.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
postId: post.id,
|
postId: post.id,
|
||||||
userId: user.id
|
userId: user.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ async function userLikePostService (
|
||||||
const like = await prisma.postLike.create({
|
const like = await prisma.postLike.create({
|
||||||
data: {
|
data: {
|
||||||
postId: post.id,
|
postId: post.id,
|
||||||
userId: user.id
|
userId: user.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return like
|
return like
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userSearchService (username: string): Promise<unknown | Error> {
|
async function userSearchService(username: string): Promise<unknown | Error> {
|
||||||
const users = await prisma.user.findMany({
|
const users = await prisma.user.findMany({
|
||||||
where: {
|
where: {
|
||||||
username: {
|
username: {
|
||||||
contains: username
|
contains: username,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
profileImage: true
|
profileImage: true,
|
||||||
},
|
},
|
||||||
take: 10
|
take: 10,
|
||||||
})
|
})
|
||||||
return users
|
return users
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ import type User from 'interfaces/user'
|
||||||
const passwordRegex = /^(?=.*[0-9])(?=.*[!@#$%^&*_])[a-zA-Z0-9!@#$%^&*_]{8,}$/
|
const passwordRegex = /^(?=.*[0-9])(?=.*[!@#$%^&*_])[a-zA-Z0-9!@#$%^&*_]{8,}$/
|
||||||
const usernameRegex = /^[a-zA-Z0-9_.]{5,15}$/
|
const usernameRegex = /^[a-zA-Z0-9_.]{5,15}$/
|
||||||
|
|
||||||
async function userSignupService ({
|
async function userSignupService({
|
||||||
username,
|
username,
|
||||||
email,
|
email,
|
||||||
password
|
password,
|
||||||
}: User): Promise<Record<string, unknown> | Error> {
|
}: User): Promise<Record<string, unknown> | Error> {
|
||||||
if (username === undefined || email === undefined || password === undefined) {
|
if (username === undefined || email === undefined || password === undefined) {
|
||||||
return new Error('Missing fields')
|
return new Error('Missing fields')
|
||||||
|
@ -17,13 +17,13 @@ async function userSignupService ({
|
||||||
|
|
||||||
if (!passwordRegex.test(password)) {
|
if (!passwordRegex.test(password)) {
|
||||||
return new Error(
|
return new Error(
|
||||||
'Password must have at least 8 characters, one number and one special character.'
|
'Password must have at least 8 characters, one number and one special character.',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!usernameRegex.test(username)) {
|
if (!usernameRegex.test(username)) {
|
||||||
return new Error(
|
return new Error(
|
||||||
'Username not allowed. Only alphanumerics characters (uppercase and lowercase words), underscore, dots and it must be between 5 and 15 characters'
|
'Username not allowed. Only alphanumerics characters (uppercase and lowercase words), underscore, dots and it must be between 5 and 15 characters',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,13 +46,13 @@ async function userSignupService ({
|
||||||
data: {
|
data: {
|
||||||
username: username.toLowerCase(),
|
username: username.toLowerCase(),
|
||||||
email,
|
email,
|
||||||
password: hashedPassword
|
password: hashedPassword,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
createdAt: true
|
createdAt: true,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type User from 'interfaces/user'
|
import type User from 'interfaces/user'
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userUpdateEmailService ({
|
async function userUpdateEmailService({
|
||||||
id,
|
id,
|
||||||
email
|
email,
|
||||||
}: User): Promise<Record<string, unknown> | Error> {
|
}: User): Promise<Record<string, unknown> | Error> {
|
||||||
const user = await prisma.user.findFirst({ where: { id } })
|
const user = await prisma.user.findFirst({ where: { id } })
|
||||||
|
|
||||||
|
@ -24,16 +24,16 @@ async function userUpdateEmailService ({
|
||||||
|
|
||||||
await prisma.user.update({
|
await prisma.user.update({
|
||||||
where: {
|
where: {
|
||||||
id
|
id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
email: email ?? user.email
|
email: email ?? user.email,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
createdAt: true
|
createdAt: true,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return { message: 'Successfully updated user email' }
|
return { message: 'Successfully updated user email' }
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import type User from 'interfaces/user'
|
import type User from 'interfaces/user'
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userUpdateNameService ({
|
async function userUpdateNameService({
|
||||||
id,
|
id,
|
||||||
displayName,
|
displayName,
|
||||||
username
|
username,
|
||||||
}: User): Promise<Record<string, unknown> | Error> {
|
}: User): Promise<Record<string, unknown> | Error> {
|
||||||
const user = await prisma.user.findFirst({ where: { id } })
|
const user = await prisma.user.findFirst({ where: { id } })
|
||||||
|
|
||||||
|
@ -28,17 +28,17 @@ async function userUpdateNameService ({
|
||||||
|
|
||||||
const updatedUser = await prisma.user.update({
|
const updatedUser = await prisma.user.update({
|
||||||
where: {
|
where: {
|
||||||
id
|
id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
displayName: displayName ?? user.displayName,
|
displayName: displayName ?? user.displayName,
|
||||||
username: username ?? user.username
|
username: username ?? user.username,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
createdAt: true
|
createdAt: true,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return updatedUser
|
return updatedUser
|
||||||
|
|
|
@ -3,14 +3,14 @@ import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
const passwordRegex = /^(?=.*[0-9])(?=.*[!@#$%^&*_])[a-zA-Z0-9!@#$%^&*_]{8,}$/
|
const passwordRegex = /^(?=.*[0-9])(?=.*[!@#$%^&*_])[a-zA-Z0-9!@#$%^&*_]{8,}$/
|
||||||
|
|
||||||
async function userUpdatePasswordService (
|
async function userUpdatePasswordService(
|
||||||
id: string,
|
id: string,
|
||||||
currentPassword: string,
|
currentPassword: string,
|
||||||
newPassword: string
|
newPassword: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
if (!passwordRegex.test(newPassword)) {
|
if (!passwordRegex.test(newPassword)) {
|
||||||
return new Error(
|
return new Error(
|
||||||
'New password must have at least 8 characters, one number and one special character.'
|
'New password must have at least 8 characters, one number and one special character.',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ async function userUpdatePasswordService (
|
||||||
|
|
||||||
const validPassword = await bcrypt.compare(
|
const validPassword = await bcrypt.compare(
|
||||||
currentPassword.replace(/ /g, ''),
|
currentPassword.replace(/ /g, ''),
|
||||||
user.password
|
user.password,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!validPassword) {
|
if (!validPassword) {
|
||||||
|
@ -38,16 +38,16 @@ async function userUpdatePasswordService (
|
||||||
|
|
||||||
await prisma.user.update({
|
await prisma.user.update({
|
||||||
where: {
|
where: {
|
||||||
id
|
id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
password: hashedPassword
|
password: hashedPassword,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
displayName: true,
|
displayName: true,
|
||||||
username: true,
|
username: true,
|
||||||
createdAt: true
|
createdAt: true,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return { message: 'Successfully updated user password' }
|
return { message: 'Successfully updated user password' }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import prisma from 'clients/prisma-client'
|
import prisma from 'clients/prisma-client'
|
||||||
|
|
||||||
async function userUploadPictureService (
|
async function userUploadPictureService(
|
||||||
authorId: string,
|
authorId: string,
|
||||||
url: string
|
url: string,
|
||||||
): Promise<Record<string, unknown> | Error> {
|
): Promise<Record<string, unknown> | Error> {
|
||||||
const user = await prisma.user.findFirst({ where: { id: authorId } })
|
const user = await prisma.user.findFirst({ where: { id: authorId } })
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@ async function userUploadPictureService (
|
||||||
|
|
||||||
const updatedUser = await prisma.user.update({
|
const updatedUser = await prisma.user.update({
|
||||||
where: {
|
where: {
|
||||||
id: authorId
|
id: authorId,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
profileImage: url
|
profileImage: url,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
profileImage: true
|
profileImage: true,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return updatedUser
|
return updatedUser
|
||||||
|
|
|
@ -3,11 +3,11 @@ import logger from 'helpers/logger'
|
||||||
import { Server } from 'socket.io'
|
import { Server } from 'socket.io'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||||
export default function createSocketIOInstance (httpServer: any) {
|
export default function createSocketIOInstance(httpServer: any) {
|
||||||
const io = new Server(httpServer, {
|
const io = new Server(httpServer, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: process.env.CORS_ORIGIN ?? '*'
|
origin: process.env.CORS_ORIGIN ?? '*',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
io.use(async (socket, next) => {
|
io.use(async (socket, next) => {
|
||||||
|
@ -20,11 +20,11 @@ export default function createSocketIOInstance (httpServer: any) {
|
||||||
|
|
||||||
await prisma.user.update({
|
await prisma.user.update({
|
||||||
where: {
|
where: {
|
||||||
id: socket.handshake.auth.id
|
id: socket.handshake.auth.id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
socketId: socket.id
|
socketId: socket.id,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
@ -36,7 +36,7 @@ export default function createSocketIOInstance (httpServer: any) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
io.on('connection', (_) => {
|
io.on('connection', _ => {
|
||||||
logger.info('Placeholder')
|
logger.info('Placeholder')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,4 @@
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue