@financial-times/dotcom-middleware-app-context 7.2.7 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.d.ts +6 -0
- package/dist/tsconfig.tsbuildinfo +3260 -0
- package/package.json +7 -5
- package/src/index.ts +0 -38
package/package.json
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "@financial-times/dotcom-middleware-app-context",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.3.1",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/node/index.js",
|
6
6
|
"types": "src/index.ts",
|
7
7
|
"scripts": {
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
9
|
-
"tsc": "../../node_modules/.bin/tsc --incremental",
|
10
9
|
"clean": "npm run clean:dist && npm run clean:node_modules",
|
11
10
|
"clean:dist": "rm -rf dist",
|
12
11
|
"clean:node_modules": "rm -rf node_modules",
|
12
|
+
"build:node": "tsc",
|
13
13
|
"build": "npm run build:node",
|
14
14
|
"dev": "npm run build:node -- --watch",
|
15
|
-
"build:node": "npm run tsc -- --module commonjs --outDir ./dist/node",
|
16
15
|
"preinstall": "[ \"$INIT_CWD\" != \"$PWD\" ] || npm_config_yes=true npx check-engine"
|
17
16
|
},
|
18
17
|
"keywords": [],
|
@@ -25,12 +24,15 @@
|
|
25
24
|
"node-mocks-http": "^1.7.5"
|
26
25
|
},
|
27
26
|
"dependencies": {
|
28
|
-
"@financial-times/dotcom-server-app-context": "
|
27
|
+
"@financial-times/dotcom-server-app-context": "file:../dotcom-server-app-context"
|
29
28
|
},
|
30
29
|
"engines": {
|
31
30
|
"node": ">= 14.0.0",
|
32
31
|
"npm": "7.x || 8.x"
|
33
32
|
},
|
33
|
+
"files": [
|
34
|
+
"dist/"
|
35
|
+
],
|
34
36
|
"repository": {
|
35
37
|
"type": "git",
|
36
38
|
"repository": "https://github.com/Financial-Times/dotcom-page-kit.git",
|
@@ -40,4 +42,4 @@
|
|
40
42
|
"volta": {
|
41
43
|
"extends": "../../package.json"
|
42
44
|
}
|
43
|
-
}
|
45
|
+
}
|
package/src/index.ts
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
import { Request, Response, NextFunction } from 'express'
|
2
|
-
import pkg from '@financial-times/dotcom-server-app-context/package.json'
|
3
|
-
import { AppContext, TAppContext } from '@financial-times/dotcom-server-app-context'
|
4
|
-
|
5
|
-
export type TMiddlewareOptions = {
|
6
|
-
appContext?: Partial<TAppContext>
|
7
|
-
}
|
8
|
-
|
9
|
-
export function init(options: TMiddlewareOptions = {}) {
|
10
|
-
return (request: Request, response: Response, next: NextFunction) => {
|
11
|
-
const appContext = {
|
12
|
-
// TODO: improve how we retrieve the app name.
|
13
|
-
// HACK: this is plucked from the debug headers set by n-express:
|
14
|
-
// https://github.com/Financial-Times/n-express/blob/HEAD/main.js#L76-L80
|
15
|
-
appName: response.get('ft-app-name'),
|
16
|
-
product: 'next',
|
17
|
-
edition: request.get('ft-edition'),
|
18
|
-
appVersion: process.env.CIRCLE_SHA1 || process.env.SOURCE_VERSION || process.env.HEROKU_SLUG_COMMIT,
|
19
|
-
// Many headers are set to a default value of "-" by the CDN so we need to ignore those
|
20
|
-
// https://github.com/Financial-Times/ft.com-cdn/blob/HEAD/src/vcl/next-preflight.vcl
|
21
|
-
abTestState: request.get('ft-ab') === '-' ? undefined : request.get('ft-ab'),
|
22
|
-
isProduction: process.env.NODE_ENV === 'production',
|
23
|
-
// This is set by the membership session service as part of preflight
|
24
|
-
// https://github.com/Financial-Times/next-preflight/blob/HEAD/server/tasks/membership/session.js
|
25
|
-
isUserLoggedIn: request.get('ft-anonymous-user') === 'false',
|
26
|
-
pageKitVersion: pkg.version === '0.0.0' ? 'development' : pkg.version,
|
27
|
-
...options.appContext
|
28
|
-
}
|
29
|
-
|
30
|
-
try {
|
31
|
-
response.locals.appContext = new AppContext({ appContext })
|
32
|
-
} catch (error) {
|
33
|
-
next(error)
|
34
|
-
}
|
35
|
-
|
36
|
-
next()
|
37
|
-
}
|
38
|
-
}
|