diff --git a/client/app.config.ts b/client/app.config.ts index 0f9904cf6..99145a486 100644 --- a/client/app.config.ts +++ b/client/app.config.ts @@ -4,7 +4,7 @@ import {ConfigContext, ExpoConfig} from '@expo/config'; import {version} from './package.json'; -const androidVersionCode = 34; +const androidVersionCode = 35; export default ({config}: ConfigContext): ExpoConfig => ({ ...config, diff --git a/client/assets/langs/en.json b/client/assets/langs/en.json index da6fabde8..b33233fce 100644 --- a/client/assets/langs/en.json +++ b/client/assets/langs/en.json @@ -94,6 +94,8 @@ "SEND": "Send", "SEND_LINK": "Send Link", "SETTINGS": "Settings", + "SHARE_VIDEO": "Share video", + "SHARING_VIDEO": "Sharing video...", "SIGNED_IN_WITH_APPLE": "Signed in with Apple", "SIGNED_IN_WITH_EMAIL": "Signed in with Email", "SIGNED_IN_WITH_FACEBOOK": "Signed in with Facebook", @@ -122,7 +124,5 @@ "VIDEO": "Video", "WARNING": "Warning", "WRITE_MESSAGE": "Write message...", - "YES": "Yes", - "SHARE_VIDEO": "Share video", - "SHARING_VIDEO": "Sharing video..." + "YES": "Yes" } \ No newline at end of file diff --git a/client/assets/langs/ko.json b/client/assets/langs/ko.json index d3fa298f8..f718656dd 100644 --- a/client/assets/langs/ko.json +++ b/client/assets/langs/ko.json @@ -94,6 +94,8 @@ "SEND": "보내기", "SEND_LINK": "링크 보내기", "SETTINGS": "설정", + "SHARE_VIDEO": "비디오 공유", + "SHARING_VIDEO": "비디오를 공유합니다...", "SIGNED_IN_WITH_APPLE": "애플 계정으로 로그인 됨", "SIGNED_IN_WITH_EMAIL": "이메일로 로그인 됨", "SIGNED_IN_WITH_FACEBOOK": "페이스북 계정으로 로그인 됨", @@ -122,7 +124,5 @@ "VIDEO": "비디오", "WARNING": "경고", "WRITE_MESSAGE": "메세지를 입력해주세요…", - "YES": "예", - "SHARE_VIDEO": "비디오 공유", - "SHARING_VIDEO": "비디오를 공유합니다..." + "YES": "예" } diff --git a/client/package.json b/client/package.json index 25b0d852c..54fc46426 100644 --- a/client/package.json +++ b/client/package.json @@ -1,7 +1,7 @@ { "name": "hackatalk", "private": true, - "version": "1.14.0", + "version": "1.15.0", "main": "node_modules/expo/AppEntry.js", "description": "Opensource chat app", "author": "dooboolab", @@ -45,7 +45,7 @@ "@react-navigation/native": "^6.0.8", "@react-navigation/stack": "^6.1.1", "apollo-upload-client": "^17.0.0", - "dooboo-ui": "^0.1.61", + "dooboo-ui": "^0.1.62", "expo": "^44.0.6", "expo-ads-admob": "~12.0.0", "expo-app-loading": "~1.3.0", @@ -72,7 +72,7 @@ "immer": "^9.0.12", "mime": "^3.0.0", "moment": "^2.29.1", - "nanoid": "^3.3.1", + "nanoid": "^3.3.2", "react": "17.0.2", "react-native": "0.64.3", "react-native-appearance": "~0.3.4", @@ -108,7 +108,7 @@ "@babel/preset-react": "^7.16.7", "@babel/preset-typescript": "^7.16.7", "@babel/runtime": "^7.17.8", - "@dooboo/eslint-config": "^1.3.3", + "@dooboo/eslint-config": "^1.3.4", "@emotion/babel-plugin": "^11.7.2", "@expo/metro-config": "^0.3.12", "@expo/webpack-config": "~0.16.19", @@ -130,7 +130,7 @@ "@types/react": "~17.0.43", "@types/react-native": "~0.67.3", "@types/react-native-modalbox": "^1.4.10", - "@types/react-relay": "^13.0.1", + "@types/react-relay": "^13.0.2", "@types/react-responsive": "^8.0.5", "@types/react-test-renderer": "^17.0", "@types/relay-test-utils": "^6.0.5", diff --git a/client/src/__generated__/UploadSingleUploadMutation.graphql.ts b/client/src/__generated__/UploadSingleUploadMutation.graphql.ts index 3d94dbecd..e228cbe96 100644 --- a/client/src/__generated__/UploadSingleUploadMutation.graphql.ts +++ b/client/src/__generated__/UploadSingleUploadMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<4604d13a1c69bb0cfe12416b1fd97bc3>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -11,7 +11,7 @@ import { ConcreteRequest, Mutation } from 'relay-runtime'; export type UploadSingleUploadMutation$variables = { file: any; - dir: string; + dir?: string | null; }; export type UploadSingleUploadMutation$data = { readonly singleUpload: string; @@ -76,16 +76,16 @@ return { "selections": (v2/*: any*/) }, "params": { - "cacheID": "f6726252665c86c713fd52fdd932b156", + "cacheID": "e825a4c3ff6932ef99e70a6a8c7eb178", "id": null, "metadata": {}, "name": "UploadSingleUploadMutation", "operationKind": "mutation", - "text": "mutation UploadSingleUploadMutation(\n $file: Upload!\n $dir: String!\n) {\n singleUpload(file: $file, dir: $dir)\n}\n" + "text": "mutation UploadSingleUploadMutation(\n $file: Upload!\n $dir: String\n) {\n singleUpload(file: $file, dir: $dir)\n}\n" } }; })(); -(node as any).hash = "7fe23bbe646db6d5a4b98daaeb77693a"; +(node as any).hash = "c0bf0e7a939336270a11e1445098ffeb"; export default node; diff --git a/client/src/relay/fetch.ts b/client/src/relay/fetch.ts index 83d57e707..e85567357 100644 --- a/client/src/relay/fetch.ts +++ b/client/src/relay/fetch.ts @@ -44,6 +44,7 @@ const fetchGraphQL: FetchFunction = async ( formData.append('operations', query); let map: {[key: number]: string[]} = {}; + let idx = 0; const prefix = 'variables'; @@ -51,19 +52,20 @@ const fetchGraphQL: FetchFunction = async ( const files = uploadables[field]; if (Array.isArray(files)) { + // multi uploads for (let i in files) { map[idx] = [`${prefix}.${field}.${i}`]; formData.append(`${idx}`, files[i]); + idx++; } formData.append('map', JSON.stringify(map)); } else { + // single upload map[idx] = [`${prefix}.${field}`]; formData.append('map', JSON.stringify(map)); formData.append(`${idx}`, files); } - - idx++; }); formData.append('map', JSON.stringify(map)); diff --git a/client/src/relay/queries/Upload.tsx b/client/src/relay/queries/Upload.tsx index c996e3fa5..976ea3970 100644 --- a/client/src/relay/queries/Upload.tsx +++ b/client/src/relay/queries/Upload.tsx @@ -1,7 +1,7 @@ import {graphql} from 'react-relay'; export const singleUpload = graphql` - mutation UploadSingleUploadMutation($file: Upload!, $dir: String!) { + mutation UploadSingleUploadMutation($file: Upload!, $dir: String) { singleUpload(file: $file, dir: $dir) } `; diff --git a/client/yarn.lock b/client/yarn.lock index 2579bb2f3..744249b0d 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -1178,14 +1178,14 @@ dependencies: react-responsive "^8.2.0" -"@dooboo/eslint-config@^1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@dooboo/eslint-config/-/eslint-config-1.3.3.tgz#27183dfb34748d9037a72aa30a4a8e1348d08ae0" - integrity sha512-7bTCNsMVxO6+qBZuFE+pxpv/qEnaGpG5M18ZD2sVFP/H4pph2UJOwgjXwYnkxB8519kYmQ3eFUBvzxK6g2M/+A== +"@dooboo/eslint-config@^1.3.4": + version "1.3.4" + resolved "https://registry.yarnpkg.com/@dooboo/eslint-config/-/eslint-config-1.3.4.tgz#77f1a69c1278e4c9fbdf85bf659fdb9f5453ec61" + integrity sha512-rzxxuRBgs7EAIp9CDxET1gHOE0ltEXybZpQzgxES9liEyvdBRbVDhtypg4cpyKrlZFLmNX3aEDZwl6/DLUQeVQ== dependencies: "@react-native-community/eslint-config" "^3.0.1" - "@typescript-eslint/eslint-plugin" "^5.14.0" - "@typescript-eslint/parser" "^5.14.0" + "@typescript-eslint/eslint-plugin" "^5.17.0" + "@typescript-eslint/parser" "^5.17.0" eslint-plugin-flowtype "^8.0.3" eslint-plugin-prettier "^4.0.0" @@ -3420,7 +3420,7 @@ dependencies: "@types/react" "*" -"@types/react-relay@*", "@types/react-relay@^13.0.1": +"@types/react-relay@*": version "13.0.1" resolved "https://registry.yarnpkg.com/@types/react-relay/-/react-relay-13.0.1.tgz#acc25817b29febdc6b251fa076ccbe6ee9b97b1f" integrity sha512-nEjkbipJ84oOvjDz8X5bqkpaPjq3tpQekaS9P/3rlePIigttN3m3S6HMthKCeRWwXeKNdVqrMcmdPXI0TQly3g== @@ -3428,6 +3428,14 @@ "@types/react" "*" "@types/relay-runtime" "*" +"@types/react-relay@^13.0.2": + version "13.0.2" + resolved "https://registry.yarnpkg.com/@types/react-relay/-/react-relay-13.0.2.tgz#85ac65b13b7a67f8c75fc32dd175160c28d3cc9b" + integrity sha512-QyPV/BVKyv5/3bZKILIJYa2dM1r2HOMYNe6vuFbs/4G1uWj9RCbJiTcWFK2OxH3y70p1k9/A5gPS3lFDm0CvHQ== + dependencies: + "@types/react" "*" + "@types/relay-runtime" "*" + "@types/react-responsive@^8.0.5": version "8.0.5" resolved "https://registry.yarnpkg.com/@types/react-responsive/-/react-responsive-8.0.5.tgz#77769862d2a0711434feb972be08e3e6c334440a" @@ -3560,14 +3568,14 @@ semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/eslint-plugin@^5.14.0": - version "5.16.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.16.0.tgz#78f246dd8d1b528fc5bfca99a8a64d4023a3d86d" - integrity sha512-SJoba1edXvQRMmNI505Uo4XmGbxCK9ARQpkvOd00anxzri9RNQk0DDCxD+LIl+jYhkzOJiOMMKYEHnHEODjdCw== +"@typescript-eslint/eslint-plugin@^5.17.0": + version "5.17.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.17.0.tgz#704eb4e75039000531255672bf1c85ee85cf1d67" + integrity sha512-qVstvQilEd89HJk3qcbKt/zZrfBZ+9h2ynpAGlWjWiizA7m/MtLT9RoX6gjtpE500vfIg8jogAkDzdCxbsFASQ== dependencies: - "@typescript-eslint/scope-manager" "5.16.0" - "@typescript-eslint/type-utils" "5.16.0" - "@typescript-eslint/utils" "5.16.0" + "@typescript-eslint/scope-manager" "5.17.0" + "@typescript-eslint/type-utils" "5.17.0" + "@typescript-eslint/utils" "5.17.0" debug "^4.3.2" functional-red-black-tree "^1.0.1" ignore "^5.1.8" @@ -3597,14 +3605,14 @@ "@typescript-eslint/typescript-estree" "4.33.0" debug "^4.3.1" -"@typescript-eslint/parser@^5.14.0": - version "5.16.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.16.0.tgz#e4de1bde4b4dad5b6124d3da227347616ed55508" - integrity sha512-fkDq86F0zl8FicnJtdXakFs4lnuebH6ZADDw6CYQv0UZeIjHvmEw87m9/29nk2Dv5Lmdp0zQ3zDQhiMWQf/GbA== +"@typescript-eslint/parser@^5.17.0": + version "5.17.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.17.0.tgz#7def77d5bcd8458d12d52909118cf3f0a45f89d5" + integrity sha512-aRzW9Jg5Rlj2t2/crzhA2f23SIYFlF9mchGudyP0uiD6SenIxzKoLjwzHbafgHn39dNV/TV7xwQkLfFTZlJ4ig== dependencies: - "@typescript-eslint/scope-manager" "5.16.0" - "@typescript-eslint/types" "5.16.0" - "@typescript-eslint/typescript-estree" "5.16.0" + "@typescript-eslint/scope-manager" "5.17.0" + "@typescript-eslint/types" "5.17.0" + "@typescript-eslint/typescript-estree" "5.17.0" debug "^4.3.2" "@typescript-eslint/scope-manager@4.33.0": @@ -3615,20 +3623,20 @@ "@typescript-eslint/types" "4.33.0" "@typescript-eslint/visitor-keys" "4.33.0" -"@typescript-eslint/scope-manager@5.16.0": - version "5.16.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.16.0.tgz#7e7909d64bd0c4d8aef629cdc764b9d3e1d3a69a" - integrity sha512-P+Yab2Hovg8NekLIR/mOElCDPyGgFZKhGoZA901Yax6WR6HVeGLbsqJkZ+Cvk5nts/dAlFKm8PfL43UZnWdpIQ== +"@typescript-eslint/scope-manager@5.17.0": + version "5.17.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.17.0.tgz#4cea7d0e0bc0e79eb60cad431c89120987c3f952" + integrity sha512-062iCYQF/doQ9T2WWfJohQKKN1zmmXVfAcS3xaiialiw8ZUGy05Em6QVNYJGO34/sU1a7a+90U3dUNfqUDHr3w== dependencies: - "@typescript-eslint/types" "5.16.0" - "@typescript-eslint/visitor-keys" "5.16.0" + "@typescript-eslint/types" "5.17.0" + "@typescript-eslint/visitor-keys" "5.17.0" -"@typescript-eslint/type-utils@5.16.0": - version "5.16.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.16.0.tgz#b482bdde1d7d7c0c7080f7f2f67ea9580b9e0692" - integrity sha512-SKygICv54CCRl1Vq5ewwQUJV/8padIWvPgCxlWPGO/OgQLCijY9G7lDu6H+mqfQtbzDNlVjzVWQmeqbLMBLEwQ== +"@typescript-eslint/type-utils@5.17.0": + version "5.17.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.17.0.tgz#1c4549d68c89877662224aabb29fbbebf5fc9672" + integrity sha512-3hU0RynUIlEuqMJA7dragb0/75gZmwNwFf/QJokWzPehTZousP/MNifVSgjxNcDCkM5HI2K22TjQWUmmHUINSg== dependencies: - "@typescript-eslint/utils" "5.16.0" + "@typescript-eslint/utils" "5.17.0" debug "^4.3.2" tsutils "^3.21.0" @@ -3637,10 +3645,10 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72" integrity sha512-zKp7CjQzLQImXEpLt2BUw1tvOMPfNoTAfb8l51evhYbOEEzdWyQNmHWWGPR6hwKJDAi+1VXSBmnhL9kyVTTOuQ== -"@typescript-eslint/types@5.16.0": - version "5.16.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.16.0.tgz#5827b011982950ed350f075eaecb7f47d3c643ee" - integrity sha512-oUorOwLj/3/3p/HFwrp6m/J2VfbLC8gjW5X3awpQJ/bSG+YRGFS4dpsvtQ8T2VNveV+LflQHjlLvB6v0R87z4g== +"@typescript-eslint/types@5.17.0": + version "5.17.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.17.0.tgz#861ec9e669ffa2aa9b873dd4d28d9b1ce26d216f" + integrity sha512-AgQ4rWzmCxOZLioFEjlzOI3Ch8giDWx8aUDxyNw9iOeCvD3GEYAB7dxWGQy4T/rPVe8iPmu73jPHuaSqcjKvxw== "@typescript-eslint/typescript-estree@4.33.0": version "4.33.0" @@ -3655,28 +3663,28 @@ semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/typescript-estree@5.16.0": - version "5.16.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.16.0.tgz#32259459ec62f5feddca66adc695342f30101f61" - integrity sha512-SE4VfbLWUZl9MR+ngLSARptUv2E8brY0luCdgmUevU6arZRY/KxYoLI/3V/yxaURR8tLRN7bmZtJdgmzLHI6pQ== +"@typescript-eslint/typescript-estree@5.17.0": + version "5.17.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.17.0.tgz#a7cba7dfc8f9cc2ac78c18584e684507df4f2488" + integrity sha512-X1gtjEcmM7Je+qJRhq7ZAAaNXYhTgqMkR10euC4Si6PIjb+kwEQHSxGazXUQXFyqfEXdkGf6JijUu5R0uceQzg== dependencies: - "@typescript-eslint/types" "5.16.0" - "@typescript-eslint/visitor-keys" "5.16.0" + "@typescript-eslint/types" "5.17.0" + "@typescript-eslint/visitor-keys" "5.17.0" debug "^4.3.2" globby "^11.0.4" is-glob "^4.0.3" semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/utils@5.16.0": - version "5.16.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.16.0.tgz#42218b459d6d66418a4eb199a382bdc261650679" - integrity sha512-iYej2ER6AwmejLWMWzJIHy3nPJeGDuCqf8Jnb+jAQVoPpmWzwQOfa9hWVB8GIQE5gsCv/rfN4T+AYb/V06WseQ== +"@typescript-eslint/utils@5.17.0": + version "5.17.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.17.0.tgz#549a9e1d491c6ccd3624bc3c1b098f5cfb45f306" + integrity sha512-DVvndq1QoxQH+hFv+MUQHrrWZ7gQ5KcJzyjhzcqB1Y2Xes1UQQkTRPUfRpqhS8mhTWsSb2+iyvDW1Lef5DD7vA== dependencies: "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.16.0" - "@typescript-eslint/types" "5.16.0" - "@typescript-eslint/typescript-estree" "5.16.0" + "@typescript-eslint/scope-manager" "5.17.0" + "@typescript-eslint/types" "5.17.0" + "@typescript-eslint/typescript-estree" "5.17.0" eslint-scope "^5.1.1" eslint-utils "^3.0.0" @@ -3688,12 +3696,12 @@ "@typescript-eslint/types" "4.33.0" eslint-visitor-keys "^2.0.0" -"@typescript-eslint/visitor-keys@5.16.0": - version "5.16.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.16.0.tgz#f27dc3b943e6317264c7492e390c6844cd4efbbb" - integrity sha512-jqxO8msp5vZDhikTwq9ubyMHqZ67UIvawohr4qF3KhlpL7gzSjOd+8471H3nh5LyABkaI85laEKKU8SnGUK5/g== +"@typescript-eslint/visitor-keys@5.17.0": + version "5.17.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.17.0.tgz#52daae45c61b0211b4c81b53a71841911e479128" + integrity sha512-6K/zlc4OfCagUu7Am/BD5k8PSWQOgh34Nrv9Rxe2tBzlJ7uOeJ/h7ugCGDCeEZHT6k2CJBhbk9IsbkPI0uvUkA== dependencies: - "@typescript-eslint/types" "5.16.0" + "@typescript-eslint/types" "5.17.0" eslint-visitor-keys "^3.0.0" "@webassemblyjs/ast@1.9.0": @@ -6290,10 +6298,10 @@ domutils@^2.0.0, domutils@^2.5.2, domutils@^2.8.0: domelementtype "^2.2.0" domhandler "^4.2.0" -dooboo-ui@^0.1.61: - version "0.1.61" - resolved "https://registry.yarnpkg.com/dooboo-ui/-/dooboo-ui-0.1.61.tgz#889035ab40a0f58e0469345f81144f24aa192481" - integrity sha512-wP69XSKK/+9Wjfe+70pMBlWeRgCkV9+6A9ETxH33/YNuGzFazpwgoAeyrM/2c/KyGqdnXOGy3MecwiElP2dPPw== +dooboo-ui@^0.1.62: + version "0.1.62" + resolved "https://registry.yarnpkg.com/dooboo-ui/-/dooboo-ui-0.1.62.tgz#f69e6fe3e190b78defee2e184482adc94c4ff425" + integrity sha512-0P2WMUeSMAMxiFlz8mPvwY4qWQ4BOznPiFE1F1+ESuc1eehoJvEACbu/fNei6207fEzehys8Ar9WK1cRp/DrwQ== dependencies: "@dooboo-ui/theme" "^0.4.6" dooboolab-welcome "^1.3.2" @@ -11338,11 +11346,16 @@ nan@^2.12.1: resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== -nanoid@^3.1.23, nanoid@^3.3.1: +nanoid@^3.1.23: version "3.3.1" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== +nanoid@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.2.tgz#c89622fafb4381cd221421c69ec58547a1eec557" + integrity sha512-CuHBogktKwpm5g2sRgv83jEy2ijFzBwMoYA60orPDR7ynsLijJDqgsi4RDGj3OJpy3Ieb+LYwiRmIOGyytgITA== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" diff --git a/server/html/email_verification.html b/server/html/email_verification.html index 22fa64d2d..6199b9214 100644 --- a/server/html/email_verification.html +++ b/server/html/email_verification.html @@ -59,7 +59,7 @@ - Logo + Logo diff --git a/server/html/email_verified.html b/server/html/email_verified.html index f666aeaf1..3b41051ad 100644 --- a/server/html/email_verified.html +++ b/server/html/email_verified.html @@ -59,7 +59,7 @@ - Logo + Logo diff --git a/server/html/password_reset.html b/server/html/password_reset.html index 8d8d55960..500ed8d50 100644 --- a/server/html/password_reset.html +++ b/server/html/password_reset.html @@ -60,7 +60,7 @@ - Logo + Logo diff --git a/server/package.json b/server/package.json index 58c21d5e3..4395754e0 100644 --- a/server/package.json +++ b/server/package.json @@ -5,6 +5,7 @@ "license": "MIT", "scripts": { "start": "dotenv -e ./dotenv/.env -- ts-node --transpile-only --files src/server.ts", + "start:prod": "dotenv -e ./dotenv/prod.env -- ts-node --transpile-only --files src/server.ts", "dev": "dotenv -e ./dotenv/.env -- ts-node-dev --respawn --transpile-only --files src/server.ts", "prod": "node dist/src/server", "clean": "rm -rf dist", diff --git a/server/src/apis/root.ts b/server/src/apis/root.ts index 8c5a8223b..8f1b62e60 100644 --- a/server/src/apis/root.ts +++ b/server/src/apis/root.ts @@ -5,6 +5,7 @@ import {resetPassword, verifyEmail} from '../models/User'; import {UPLOAD_FILE_SIZE_LIMIT} from '../utils/const'; import {assert} from '../utils/assert'; +import {getMimeType} from 'stream-mime-type'; import multer from 'multer'; import {prisma} from '../context'; import qs from 'querystring'; @@ -200,11 +201,14 @@ const onUploadSingle = async (req: Request, res: Response): Promise => { return; } + // const {mime} = await getMimeType(req.file.buffer); + const url = await uploadFileToAzureBlobFromStream( bufferToStream(req.file.buffer), req.body.name || `${new Date().getTime()}_${req.file.originalname ?? ''}`, req.body.dir, process.env.NODE_ENV === 'production' ? 'hackatalk' : 'hackatalkdev', + // mime, ); res.status(200).json({ diff --git a/server/src/app.ts b/server/src/app.ts index b3b726721..d30c519c6 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -4,6 +4,7 @@ import {assert} from './utils/assert'; import cors from 'cors'; import ejs from 'ejs'; import express from 'express'; +import {graphqlUploadExpress} from 'graphql-upload'; import i18Middleware from 'i18next-http-middleware'; import i18next from 'i18next'; import path from 'path'; @@ -60,6 +61,11 @@ export const createApp = (): express.Application => { app.use(express.json()); app.use(cors()); + app.use( + '/graphql', + graphqlUploadExpress({maxFileSize: 100000000, maxFiles: 10}), // 100mb + ); + app.get('/', (req, res) => { res.send(`${req.t('IT_WORKS')} - ${version}`); }); diff --git a/server/src/resolvers/Upload/mutation.ts b/server/src/resolvers/Upload/mutation.ts index 8c771c100..34caafa25 100644 --- a/server/src/resolvers/Upload/mutation.ts +++ b/server/src/resolvers/Upload/mutation.ts @@ -1,5 +1,6 @@ import {arg, mutationField, nonNull, stringArg} from 'nexus'; +import {getMimeType} from 'stream-mime-type'; import {nanoid} from 'nanoid'; import {uploadFileToAzureBlobFromStream} from '../../utils/azure'; @@ -13,11 +14,14 @@ export const singleUpload = mutationField('singleUpload', { const {createReadStream} = await file; const stream = createReadStream(); + // const {mime} = await getMimeType(stream); + return uploadFileToAzureBlobFromStream( stream, nanoid(), dir ?? '', process.env.NODE_ENV === 'production' ? 'hackatalk' : 'hackatalkdev', + // mime, ); }, }); diff --git a/server/src/resolvers/User/mutation.ts b/server/src/resolvers/User/mutation.ts index b363761f6..0993609ab 100644 --- a/server/src/resolvers/User/mutation.ts +++ b/server/src/resolvers/User/mutation.ts @@ -24,6 +24,7 @@ import {User} from '@prisma/client'; import {UserService} from '../../services/UserService'; import {assert} from '../../utils/assert'; import generator from 'generate-password'; +import {getMimeType} from 'stream-mime-type'; import {sign as jwtSignIn} from '../../utils/jwt'; import {nanoid} from 'nanoid'; import {sign} from 'jsonwebtoken'; @@ -79,12 +80,14 @@ export const signUp = mutationField('signUp', { if (photoUpload) { const {createReadStream} = await photoUpload; const stream = createReadStream(); + // const {mime} = await getMimeType(stream); uploadedURL = await uploadFileToAzureBlobFromStream( stream, nanoid(), 'profile', process.env.NODE_ENV === 'production' ? 'hackatalk' : 'hackatalkdev', + // mime, ); } @@ -163,8 +166,6 @@ export const signInWithFacebook = mutationField('signInWithFacebook', { args: {accessToken: nonNull(stringArg())}, resolve: async (_parent, {accessToken}, ctx) => { - const socialUser = await verifyFacebookId(accessToken); - const { id: facebookId, name, @@ -172,7 +173,7 @@ export const signInWithFacebook = mutationField('signInWithFacebook', { picture: { data: {url}, }, - } = socialUser; + } = await verifyFacebookId(accessToken); return UserService.signInWithSocialAccount( { @@ -220,9 +221,7 @@ export const signInWithGoogle = mutationField('signInWithGoogle', { args: {accessToken: nonNull(stringArg())}, resolve: async (_parent, {accessToken}, ctx) => { - const socialUser = await verifyGoogleId(accessToken); - - const {sub, email, name = '', picture} = socialUser; + const {sub, email, name = '', picture} = await verifyGoogleId(accessToken); assert(email, 'No email returned from Google.'); diff --git a/server/src/utils/azure.ts b/server/src/utils/azure.ts index 4447fddeb..7c21a1183 100644 --- a/server/src/utils/azure.ts +++ b/server/src/utils/azure.ts @@ -38,6 +38,7 @@ export const uploadFileToAzureBlobFromStream = async ( destFile: string, destDir: string, containerName: string, + mimeType?: string, ): Promise => { try { assert(blobService, 'Azure Storage is not initialized.'); @@ -47,7 +48,9 @@ export const uploadFileToAzureBlobFromStream = async ( .getContainerClient(containerName) .getBlockBlobClient(resolveBlobName(destFile, destDir)); - await blockBlobClient.uploadStream(stream); + await blockBlobClient.uploadStream(stream, undefined, undefined, { + blobHTTPHeaders: {blobContentType: mimeType}, + }); return blockBlobClient.url; } catch (e: any) { diff --git a/server/src/utils/error.ts b/server/src/utils/error.ts index 9fbc93e3e..3f1fe8966 100644 --- a/server/src/utils/error.ts +++ b/server/src/utils/error.ts @@ -37,6 +37,6 @@ export const ErrorEmailNotValid = (message: string): ApolloError => }); export const ErrorEmailUserExists = (message: string): ApolloError => - new ApolloError(message, 'EMAIL_FOR_USER_EXISTS', { + new ApolloError(message, 'EMAIL_USER_EXISTS', { parameter: 'email', });