Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Node 14 #980

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[ignore]
.*/node_modules/jest-validate/*
.*/node_modules/protobufjs/*
.*/node_modules/resolve/*
.*/build/*
.*/coverage/*

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '10'
node-version: '14'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
Expand Down
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## [27.0]

- **Removed** ld dependency

## [26.1]

- **Improved** add github action
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CI_BUILD_NUMBER ?= $(USER)-snapshot
VERSION ?= 27.0.$(CI_BUILD_NUMBER)
VERSION ?= 26.1.$(CI_BUILD_NUMBER)

version:
@echo $(VERSION)
26 changes: 26 additions & 0 deletions flow-typed/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,32 @@ declare type GeoLocation = {
latlon?: Array<number>,
};

// See https://docs.launchdarkly.com/docs/node-sdk-reference#section-users
declare type LaunchDarklyUser$CustomAttributes = {
RequestCountry?: string,
RequestRegion?: string,
[string]:
| string
| boolean
| number
| Array<string>
| Array<boolean>
| Array<number>,
};

declare type LaunchDarklyUser = {|
key: string,
ip?: string,
firstName?: string,
lastName?: string,
country?: string,
email?: string,
avatar?: string,
name?: string,
anonymous?: boolean,
custom?: LaunchDarklyUser$CustomAttributes,
|};

declare type ActivityInfo = {
viewName?: string,
subViewName?: string,
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "A collection of Node web application utilities for the Meetup web platform",
"engines": {
"node": "^10.22.1",
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand Down Expand Up @@ -75,8 +75,8 @@
"js-joda-timezone": "2.0.2",
"lerna": "3.15.0",
"lint-staged": "8.2.1",
"meetup-web-components": "8.0.2918",
"meetup-web-mocks": "1.0.270",
"meetup-web-components": "8.1.244-beta",
"meetup-web-mocks": "1.3.27",
"mwp-router": ">=0.0.1",
"mwp-test-utils": ">=0.0.1",
"node-fetch": "1.7.2",
Expand Down Expand Up @@ -108,4 +108,4 @@
"workspaces": [
"packages/*"
]
}
}
4 changes: 2 additions & 2 deletions packages/mwp-api-proxy-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Hapi plugin to activate the REST API proxy behavior + route",
"engines": {
"node": "^10.22.1",
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand Down Expand Up @@ -38,4 +38,4 @@
"rison": "0.1.1"
},
"devDependencies": {}
}
}
4 changes: 2 additions & 2 deletions packages/mwp-api-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Redux helpers to manage API data in a MWP app",
"engines": {
"node": "^10.22.1",
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand Down Expand Up @@ -34,4 +34,4 @@
"mwp-tracking-plugin": ">=0.0.1"
},
"devDependencies": {}
}
}
4 changes: 2 additions & 2 deletions packages/mwp-app-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "MWP application rendering tools",
"engines": {
"node": ">=10.22.1",
"node": ">=14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand Down Expand Up @@ -37,4 +37,4 @@
"escape-html": "1.0.3"
},
"devDependencies": {}
}
}
5 changes: 3 additions & 2 deletions packages/mwp-app-route-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Hapi plugin to activate the wildcard application route",
"engines": {
"node": "^10.22.1",
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand All @@ -27,6 +27,7 @@
"homepage": "https://github.com/meetup/meetup-web-platform#readme",
"dependencies": {
"electrode-csrf-jwt": "git+https://github.com/meetup/electrode-csrf-jwt.git#793431729d8fb4ee315f28709f323f198b25d460",
"launchdarkly-node-server-sdk": "5.9.0",
"redbox-react": "1.6.0"
},
"devDependencies": {},
Expand All @@ -38,4 +39,4 @@
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
}
}
48 changes: 47 additions & 1 deletion packages/mwp-app-route-plugin/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// @flow
import LaunchDarkly from 'launchdarkly-node-server-sdk';

import getRoute from './route';
import { fetchLaunchDarklySdkKey } from './util/secretsHelper';

/*
* The server app route plugin - this applies a wildcard catch-all route that
Expand All @@ -9,9 +12,52 @@ export function register(
server: HapiServer,
options: {
languageRenderers: { [string]: LanguageRenderer },
ldkey?: string,
}
) {
): Promise<any> {
server.route(getRoute(options.languageRenderers));

return fetchLaunchDarklySdkKey()
.then(launchDarklySdkKey => {
const ldClient = LaunchDarkly.init(options.ldkey || launchDarklySdkKey, {
offline: process.env.NODE_ENV === 'test',
});

server.expose('getFlags', (user: LaunchDarklyUser) => {
return ldClient.allFlagsState(user).then(
state => state.allValues(),
err => {
server.app.logger.error({
err,
member: user,
});
return {}; // return empty flags on error
}
);
});

// set up launchdarkly instance before continuing
if (ldClient.close) {
server.events.on('stop', ldClient.close);
}

// https://github.com/launchdarkly/node-client/issues/96
// use waitForInitialization to catch launch darkly failures
return ldClient.waitForInitialization().catch(error => {
console.error(error);
return {}; // return empty flags on error
});
})
.catch(error => {
console.error(error);
server.expose('getFlags', (user: LaunchDarklyUser) => {
server.app.logger.error({
error,
member: user,
});
return new Promise(resolve => resolve({})); // return empty flags on error
});
});
}

export const plugin = {
Expand Down
17 changes: 17 additions & 0 deletions packages/mwp-app-route-plugin/src/util/secretsHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @flow
import AWS from 'aws-sdk';

const secretsManager = new AWS.SecretsManager({ region: 'us-east-1' });

export function fetchLaunchDarklySdkKey(): Promise<string> {
return secretsManager
.getSecretValue({ SecretId: 'LaunchDarkly' })
.promise()
.then(({ SecretString }) => JSON.parse(SecretString).apiAccessToken)
.catch(error => {
console.error(
'The LaunchDarkly key may not have resolved properly. Double check that it is in the SecretsManager, has a name of "LaunchDarkly" and a key of "apiAccessToken"'
);
throw error;
});
}
4 changes: 2 additions & 2 deletions packages/mwp-app-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Hapi server startup module for MWP applications",
"engines": {
"node": "^10.22.1",
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand Down Expand Up @@ -45,4 +45,4 @@
"uuid": "3.3.2"
},
"devDependencies": {}
}
}
4 changes: 2 additions & 2 deletions packages/mwp-auth-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Hapi plugin providing user authentication for MWP apps",
"engines": {
"node": "^10.22.1",
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand All @@ -30,4 +30,4 @@
"uuid": "3.3.2"
},
"devDependencies": {}
}
}
8 changes: 4 additions & 4 deletions packages/mwp-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "0.0.1",
"description": "All the config you might ever need for a MWP app",
"engines": {
"node": "^10.22.1",
"yarn": "^1.9.4"
},
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"config": {},
"repository": {
"type": "git",
Expand All @@ -24,4 +24,4 @@
"stylelint-scss": "3.3.0"
},
"devDependencies": {}
}
}
4 changes: 2 additions & 2 deletions packages/mwp-cookie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Platform cookie-management code",
"engines": {
"node": "^10.22.1",
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand Down Expand Up @@ -31,4 +31,4 @@
"peerDependencies": {
"react": "^16.8.6"
}
}
}
4 changes: 2 additions & 2 deletions packages/mwp-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Core utilities for MWP apps",
"engines": {
"node": "^10.22.1",
"node": "^14.19.0",
"yarn": "^1.9.4"
},
"main": "./lib/index.js",
Expand Down Expand Up @@ -40,4 +40,4 @@
"qs": "6.7.0"
},
"devDependencies": {}
}
}
Loading