From bf89fc2b3e77fddfe50d497e493063fe4898fe41 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 22 Nov 2019 22:46:16 +0000 Subject: [PATCH] [chore] NodeJS 12 (#2722) * chore: upgraded node 12, more log lines - upgraded from 10 LTS to 12 LTS - added log line with userID to GraphQL log entry * fix: adjusted some intl formats --- .circleci/config.yml | 2 +- .nvmrc | 3 +-- Dockerfile | 2 +- doczrc.js | 6 ++---- package.json | 2 +- src/core/build/createWebpackConfig.ts | 2 +- .../UserHistoryDrawer/UserStatusDetailsContainer.tsx | 2 +- src/core/client/admin/routes/Stories/StoryRowContainer.tsx | 2 +- .../tabs/Profile/Settings/DownloadCommentsContainer.tsx | 2 +- .../app/middleware/passport/strategies/verifiers/sso.ts | 5 ----- src/core/server/graph/common/extensions/LoggerExtension.ts | 2 ++ 11 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6f3ddb6bf..3fc80b2e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ job_defaults: &job_defaults working_directory: ~/coralproject/talk resource_class: large docker: - - image: circleci/node:10 + - image: circleci/node:12 environment: <<: *job_environment diff --git a/.nvmrc b/.nvmrc index 021ea30c0..48082f72f 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1,2 +1 @@ -10 - +12 diff --git a/Dockerfile b/Dockerfile index 971a262d9..aa7987c30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:10-alpine +FROM node:12-alpine # Install build dependancies. RUN apk --no-cache add git python diff --git a/doczrc.js b/doczrc.js index 5ed9a64f4..63db934a3 100644 --- a/doczrc.js +++ b/doczrc.js @@ -1,13 +1,11 @@ // Apply all the configuration provided in the .env file. require("dotenv").config(); -const path = require("path"); const fs = require("fs"); const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin"); const extensions = [".ts", ".tsx", ".js"]; // TODO: There is some weird issue with including paths.ts here const postCSSConfigPath = "./src/core/build/postcss.config"; -const isProduction = process.NODE_ENV === "production"; const appDirectory = fs.realpathSync(process.cwd()); const styleLoader = { @@ -18,7 +16,7 @@ const styleLoader = { }, }; -export default { +module.exports = { title: "Coral 5.0", source: "./src", typescript: true, @@ -60,7 +58,7 @@ export default { "@babel/typescript", [ "@babel/env", - { targets: { node: "10.0.0" }, modules: "commonjs" }, + { targets: { node: "12.0.0" }, modules: "commonjs" }, ], ], // This is a feature of `babel-loader` for webpack (not Babel itself). diff --git a/package.json b/package.json index 9b2937d0d..415595e35 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "git://github.com/coralproject/talk.git" }, "engines": { - "node": ">=10.0.0", + "node": ">=12.0.0", "npm": ">=6.9.0" }, "bugs": "https://github.com/coralproject/talk/issues", diff --git a/src/core/build/createWebpackConfig.ts b/src/core/build/createWebpackConfig.ts index e5bf35d7e..68a24c1a9 100644 --- a/src/core/build/createWebpackConfig.ts +++ b/src/core/build/createWebpackConfig.ts @@ -392,7 +392,7 @@ export default function createWebpackConfig( "@babel/typescript", [ "@babel/env", - { targets: { node: "10.0.0" }, modules: "commonjs" }, + { targets: { node: "12.0.0" }, modules: "commonjs" }, ], ], // This is a feature of `babel-loader` for webpack (not Babel itself). diff --git a/src/core/client/admin/components/UserHistoryDrawer/UserStatusDetailsContainer.tsx b/src/core/client/admin/components/UserHistoryDrawer/UserStatusDetailsContainer.tsx index 20416ab2f..fe96a2317 100644 --- a/src/core/client/admin/components/UserHistoryDrawer/UserStatusDetailsContainer.tsx +++ b/src/core/client/admin/components/UserHistoryDrawer/UserStatusDetailsContainer.tsx @@ -37,7 +37,7 @@ const UserStatusDetailsContainer: FunctionComponent = ({ user }) => { day: "2-digit", month: "2-digit", year: "numeric", - hour: "2-digit", + hour: "numeric", minute: "2-digit", }); diff --git a/src/core/client/admin/routes/Stories/StoryRowContainer.tsx b/src/core/client/admin/routes/Stories/StoryRowContainer.tsx index 80bb012d4..fc493f700 100644 --- a/src/core/client/admin/routes/Stories/StoryRowContainer.tsx +++ b/src/core/client/admin/routes/Stories/StoryRowContainer.tsx @@ -33,7 +33,7 @@ const StoryRowContainer: FunctionComponent = props => { month: "2-digit", year: "numeric", hour12: true, - hour: "2-digit", + hour: "numeric", minute: "2-digit", }).format(new Date(publishedAt)) : null diff --git a/src/core/client/stream/tabs/Profile/Settings/DownloadCommentsContainer.tsx b/src/core/client/stream/tabs/Profile/Settings/DownloadCommentsContainer.tsx index ea4f07b73..730c9786e 100644 --- a/src/core/client/stream/tabs/Profile/Settings/DownloadCommentsContainer.tsx +++ b/src/core/client/stream/tabs/Profile/Settings/DownloadCommentsContainer.tsx @@ -41,7 +41,7 @@ const DownloadCommentsContainer: FunctionComponent = ({ viewer }) => { month: "2-digit", year: "numeric", hour12: true, - hour: "2-digit", + hour: "numeric", minute: "2-digit", timeZoneName: "short", }); diff --git a/src/core/server/app/middleware/passport/strategies/verifiers/sso.ts b/src/core/server/app/middleware/passport/strategies/verifiers/sso.ts index c21d9217f..74e7f1a46 100644 --- a/src/core/server/app/middleware/passport/strategies/verifiers/sso.ts +++ b/src/core/server/app/middleware/passport/strategies/verifiers/sso.ts @@ -84,11 +84,6 @@ export async function findOrCreateSSOUser( token: SSOToken, now = new Date() ) { - if (!token.user) { - // TODO: (wyattjoh) replace with better error. - throw new Error("token is malformed, missing user claim"); - } - // Validate the token content. const decodedToken: SSOToken = validate(SSOTokenSchema, token); diff --git a/src/core/server/graph/common/extensions/LoggerExtension.ts b/src/core/server/graph/common/extensions/LoggerExtension.ts index 146f5b03f..051a64ccb 100644 --- a/src/core/server/graph/common/extensions/LoggerExtension.ts +++ b/src/core/server/graph/common/extensions/LoggerExtension.ts @@ -23,7 +23,9 @@ export function logQuery( ctx.logger.info( { responseTime, + // deprecated: use of the `authenticated` log field is deprecated in favour of the `userID` field authenticated: ctx.user ? true : false, + userID: ctx.user ? ctx.user.id : null, ...(persisted ? // A persisted query was provided, we can pull the operation metadata // out from the persisted object.