Skip to content

Commit

Permalink
Merge pull request #5833 from ForumMagnum/node-v18
Browse files Browse the repository at this point in the history
Upgrade to node 18
  • Loading branch information
oetherington committed Oct 19, 2022
2 parents df7e745 + 9b46662 commit 112e5c4
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployBaserates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
node-version: [18.x]
environment: [baserates]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployEADev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
node-version: [18.x]
environment: [EAForum-Staging-2]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployEAProd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
node-version: [18.x]
environment: [EAForum-Production-2]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployLWAFProd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
node-version: [18.x]
environment: [Lesswrongexpress-env, AlignmentForumProd]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployLWDevel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
node-version: [18.x]
environment: [LessestWrong]
steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/unitTests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Run Unit Tests
on:
push:
Expand All @@ -11,7 +10,7 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v15.5.0
v18
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:15.5.0
FROM node:18.11.0
ENV IS_DOCKER=true
# Transcrypt dependency
RUN apt-get update && apt-get install -y bsdmainutils
Expand Down
1 change: 0 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const { build, cliopts } = require("estrella");
const fs = require('fs');
const WebSocket = require('ws');
const fetch = require("node-fetch");
const crypto = require('crypto');
const { zlib } = require("mz");

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@types/draft-convert": "^2.1.1",
"@types/draft-js": "^0.10.40",
"@types/enzyme": "^3.10.5",
"@types/express": "^4.17.8",
"@types/express": "4.17.14",
"@types/express-session": "^1.17.3",
"@types/gapi": "0.0.39",
"@types/google__maps": "^0.5.14",
Expand All @@ -92,8 +92,7 @@
"@types/moment": "^2.13.0",
"@types/mongodb": "^3.6.3",
"@types/mz": "^2.7.3",
"@types/node": "12",
"@types/node-fetch": "^2.5.6",
"@types/node": "18.11.0",
"@types/nodemailer": "^6.4.1",
"@types/papaparse": "^5.0.3",
"@types/passport": "^1.0.6",
Expand Down Expand Up @@ -132,7 +131,6 @@
"apollo-server-express": "2.15.0",
"auth0": "^2.42.0",
"bcrypt": "^5.0.1",
"body-parser": "^1.18.3",
"bowser": "^1.9.4",
"cheerio": "1.0.0-rc.9",
"chokidar": "^3.5.0",
Expand Down Expand Up @@ -206,7 +204,6 @@
"moment": "^2.29.4",
"mongodb": "^3.6.3",
"mz": "^2.7.0",
"node-fetch": "^2.6",
"nodemailer": "^6.6.1",
"papaparse": "^4.6.2",
"passport": "^0.5.2",
Expand Down Expand Up @@ -307,5 +304,8 @@
"graphql": "^14.5.8",
"graphql-tools": "^4.0.7",
"ts-node": "^10.9.1"
},
"engines": {
"node": "18.x"
}
}
14 changes: 4 additions & 10 deletions packages/lesswrong/lib/apollo/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,16 @@ export const createSchemaLink = (schema: GraphQLSchema, context: ResolverContext
* Http link is used for client side rendering
*/
export const createHttpLink = (baseUrl = '/') => {
// Type of window.fetch may differ slightly from type of the fetch used on server
let fetch: typeof window.fetch;
if (isServer) {
// We won't need to import fetch in node 18
const nodeFetch = require('node-fetch');
fetch = (url, options) => nodeFetch(url, {
const fetch: typeof globalThis.fetch = isServer
? (url, options) => globalThis.fetch(url, {
...options,
headers: {
...options?.headers,
// user agent because LW bans bot agents
'User-Agent': crosspostUserAgent,
}
});
} else {
fetch = window.fetch;
}
})
: globalThis.fetch;
return new BatchHttpLink({
uri: baseUrl + 'graphql',
credentials: baseUrl === '/' ? 'same-origin' : 'omit',
Expand Down
14 changes: 7 additions & 7 deletions packages/lesswrong/server/apolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { GraphQLError, GraphQLFormattedError } from 'graphql';
import { isDevelopment, getInstanceSettings, getServerPort } from '../lib/executionEnvironment';
import { renderWithCache, getThemeOptionsFromReq } from './vulcan-lib/apollo-ssr/renderPage';

import bodyParser from 'body-parser';
import { pickerMiddleware } from './vendor/picker';
import voyagerMiddleware from 'graphql-voyager/middleware/express';
import { graphiqlMiddleware } from './vulcan-lib/apollo-server/graphiql';
Expand Down Expand Up @@ -121,9 +120,10 @@ export function startWebserver() {
}
}))
}
app.use(bodyParser.urlencoded({ extended: true })) // We send passwords + username via urlencoded form parameters
app.use('/analyticsEvent', bodyParser.json({ limit: '50mb' }));
app.use('/ckeditor-webhook', bodyParser.json({ limit: '50mb' }));

app.use(express.urlencoded({ extended: true })); // We send passwords + username via urlencoded form parameters
app.use('/analyticsEvent', express.json({ limit: '50mb' }));
app.use('/ckeditor-webhook', express.json({ limit: '50mb' }));

addStripeMiddleware(addMiddleware);
addAuthMiddlewares(addMiddleware);
Expand Down Expand Up @@ -154,7 +154,7 @@ export function startWebserver() {
//tracing: isDevelopment,
tracing: false,
cacheControl: true,
context: async ({ req, res }) => {
context: async ({ req, res }: { req: express.Request, res: express.Response }) => {
const user = await getUserFromReq(req);
const context = await computeContextFromUser(user, req, res);
configureSentryScope(context);
Expand All @@ -163,8 +163,8 @@ export function startWebserver() {
plugins: [new ApolloServerLogging()]
});

app.use('/graphql', bodyParser.json({ limit: '50mb' }));
app.use('/graphql', bodyParser.text({ type: 'application/graphql' }));
app.use('/graphql', express.json({ limit: '50mb' }));
app.use('/graphql', express.text({ type: 'application/graphql' }));
apolloServer.applyMiddleware({ app })

addStaticRoute("/js/bundle.js", ({query}, req, res, context) => {
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/callbacks/userCallbacks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import fetch from "node-fetch";
import md5 from "md5";
import Users from "../../lib/collections/users/collection";
import { userGetGroups } from '../../lib/vulcan-users/permissions';
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/ckEditor/ckEditorWebhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Users } from '../../lib/collections/users/collection';
import { Posts } from '../../lib/collections/posts/collection';
import { createMutator } from '../vulcan-lib/mutators';
import { createNotifications } from '../notificationCallbacksHelpers';
import fetch from 'node-fetch';
import crypto from 'crypto';
import fs from 'fs';
import * as _ from 'underscore';
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/fmCrosspost/crosspost.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from "node-fetch";
import Users from "../../lib/collections/users/collection";
import { randomId } from "../../lib/random";
import { Crosspost, UpdateCrosspostPayload, CrosspostPayload } from "./types";
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/fmCrosspost/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { ConnectCrossposterArgs, UnlinkCrossposterPayload } from "./types";
import { ApiRoute, apiRoutes, makeApiUrl } from "./routes";
import { signToken } from "./tokens";
import type { Request } from "express";
import fetch from "node-fetch";
import { crosspostUserAgent } from "../../lib/apollo/links";

const getUserId = (req?: Request) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/lesswrong/server/fmCrosspost/routes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fmCrosspostBaseUrlSetting } from "../../lib/instanceSettings";
import { combineUrls } from "../../lib/vulcan-lib";
import { json } from "body-parser";
import type { Application, Request, Response } from "express";
import { Application, Request, Response, json } from "express";
import {
onCrosspostTokenRequest,
onConnectCrossposterRequest,
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/gatherTownCron.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { addCronJob, removeCronJob } from './cronUtil';
import { createMutator, Globals } from './vulcan-lib';
import { LWEvents } from '../lib/collections/lwevents/collection';
import fetch from 'node-fetch';
import WebSocket from 'ws';
import { DatabaseServerSetting } from './databaseSettings';
import { gatherTownRoomId, gatherTownRoomName } from '../lib/publicSettings';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Users from '../../lib/collections/users/collection';
import { createMutator, Utils } from '../vulcan-lib';
import { Posts } from '../../lib/collections/posts';
import { mapsAPIKeySetting } from '../../components/form-components/LocationFormComponent';
import fetch from 'node-fetch';
import { getLocalTime } from '../mapsUtils';
import {userFindOneByEmail} from "../../lib/collections/users/commonQueries";

Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/resolvers/arbitalPageData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { addGraphQLSchema, addGraphQLResolvers, addGraphQLQuery } from '../../lib/vulcan-lib/graphql';
import fetch from 'node-fetch'
import markdownIt from 'markdown-it'
import markdownItMathjax from '../editor/markdown-mathjax'
import { mjPagePromise } from '../editor/make_editable_callbacks';
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/resolvers/elicitPredictions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { addGraphQLSchema, addGraphQLResolvers, addGraphQLQuery, addGraphQLMutation } from '../../lib/vulcan-lib/graphql';
import fetch from 'node-fetch'
import { DatabaseServerSetting } from '../databaseSettings';
import { generateIdResolverSingle } from '../../lib/utils/schemaUtils';
import { elicitSourceURL } from '../../lib/publicSettings';
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/resolvers/mozillaHubsData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { addGraphQLSchema, addGraphQLResolvers, addGraphQLQuery } from '../../lib/vulcan-lib/graphql';
import fetch from 'node-fetch'
import { DatabaseServerSetting } from '../databaseSettings';

const MozillaHubsData = `type MozillaHubsData {
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'node-fetch';
import * as _ from 'underscore';

// Bulk apply a js function to a mongo collection; this is possibly less
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import cheerio from 'cheerio'
import fetch from 'node-fetch'

function scrapeProperties(html) {
const $ = cheerio.load(html)
Expand Down
1 change: 0 additions & 1 deletion packages/lesswrong/server/zohoUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'node-fetch';
import { DatabaseServerSetting } from './databaseSettings';

const zohoClientId = new DatabaseServerSetting('zoho.clientId', '')
Expand Down
29 changes: 18 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3032,7 +3032,7 @@
dependencies:
"@types/express" "*"

"@types/express@*", "@types/express@^4.0.35", "@types/express@^4.17.8":
"@types/express@*", "@types/express@^4.0.35":
version "4.17.9"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.9.tgz"
integrity sha512-SDzEIZInC4sivGIFY4Sz1GG6J9UObPwCInYJjko2jzOf/Imx/dlpume6Xxwj1ORL82tBbmN4cPDIDkLbWHk9hw==
Expand All @@ -3042,6 +3042,16 @@
"@types/qs" "*"
"@types/serve-static" "*"

"@types/express@4.17.14":
version "4.17.14"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.14.tgz#143ea0557249bc1b3b54f15db4c81c3d4eb3569c"
integrity sha512-TEbt+vaPFQ+xpxFLFssxUDXj5cWCxZJjIcB7Yg0k0GMHGtgtQgpvx/MUQUeAkNbA9AAGrwkAsoeItdTgS7FMyg==
dependencies:
"@types/body-parser" "*"
"@types/express-serve-static-core" "^4.17.18"
"@types/qs" "*"
"@types/serve-static" "*"

"@types/express@4.17.4":
version "4.17.4"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.4.tgz"
Expand Down Expand Up @@ -3392,19 +3402,16 @@
"@types/node" "*"
"@types/sax" "*"

"@types/node-fetch@^2.5.6":
version "2.5.7"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.7.tgz"
integrity sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==
dependencies:
"@types/node" "*"
form-data "^3.0.0"

"@types/node@*", "@types/node@12":
"@types/node@*":
version "12.19.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.19.8.tgz"
integrity sha512-D4k2kNi0URNBxIRCb1khTnkWNHv8KSL1owPmS/K5e5t8B2GzMReY7AsJIY1BnP5KdlgC4rj9jk2IkDMasIE7xg==

"@types/node@18.11.0":
version "18.11.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.0.tgz#f38c7139247a1d619f6cc6f27b072606af7c289d"
integrity sha512-IOXCvVRToe7e0ny7HpT/X9Rb2RYtElG1a+VshjwT00HxrM2dWBApHQoqsI6WiY7Q03vdf2bCrIGzVrkF/5t10w==

"@types/node@>=13.7.0":
version "18.8.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.8.4.tgz#54be907698f40de8a45770b48486aa3cbd3adff7"
Expand Down Expand Up @@ -11823,7 +11830,7 @@ node-fetch@^1.0.1:
encoding "^0.1.11"
is-stream "^1.0.1"

node-fetch@^2.6, node-fetch@^2.6.7:
node-fetch@^2.6.7:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
Expand Down

0 comments on commit 112e5c4

Please sign in to comment.