@financial-times/dotcom-middleware-asset-loader 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/createMiddleware.d.ts +4 -0
- package/dist/node/createStaticHost.d.ts +4 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/tsconfig.tsbuildinfo +3266 -0
- package/package.json +7 -5
- package/src/createMiddleware.ts +0 -12
- package/src/createStaticHost.ts +0 -8
- package/src/index.ts +0 -23
- package/src/options.d.ts +0 -9
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/dotcom-middleware-asset-loader",
|
|
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
|
-
"build:node": "npm run tsc -- --module commonjs --outDir ./dist/node",
|
|
15
14
|
"dev": "npm run build:node -- --watch",
|
|
16
15
|
"preinstall": "[ \"$INIT_CWD\" != \"$PWD\" ] || npm_config_yes=true npx check-engine"
|
|
17
16
|
},
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
"author": "",
|
|
20
19
|
"license": "MIT",
|
|
21
20
|
"dependencies": {
|
|
22
|
-
"@financial-times/dotcom-server-asset-loader": "
|
|
21
|
+
"@financial-times/dotcom-server-asset-loader": "file:../../packages/dotcom-server-asset-loader",
|
|
23
22
|
"express": "^4.16.4"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
@@ -32,6 +31,9 @@
|
|
|
32
31
|
"node": ">= 14.0.0",
|
|
33
32
|
"npm": "7.x || 8.x"
|
|
34
33
|
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/"
|
|
36
|
+
],
|
|
35
37
|
"repository": {
|
|
36
38
|
"type": "git",
|
|
37
39
|
"repository": "https://github.com/Financial-Times/dotcom-page-kit.git",
|
|
@@ -41,4 +43,4 @@
|
|
|
41
43
|
"volta": {
|
|
42
44
|
"extends": "../../package.json"
|
|
43
45
|
}
|
|
44
|
-
}
|
|
46
|
+
}
|
package/src/createMiddleware.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AssetLoader } from '@financial-times/dotcom-server-asset-loader'
|
|
2
|
-
import { MiddlewareOptions } from './options'
|
|
3
|
-
import { Handler, Request, Response, NextFunction } from 'express'
|
|
4
|
-
|
|
5
|
-
export default (options: MiddlewareOptions): Handler => {
|
|
6
|
-
const loader = new AssetLoader(options)
|
|
7
|
-
|
|
8
|
-
return (_: Request, response: Response, next: NextFunction) => {
|
|
9
|
-
response.locals.assetLoader = loader
|
|
10
|
-
next()
|
|
11
|
-
}
|
|
12
|
-
}
|
package/src/createStaticHost.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import express, { Handler } from 'express'
|
|
2
|
-
import { MiddlewareOptions } from './options'
|
|
3
|
-
|
|
4
|
-
export default (options: MiddlewareOptions): Handler => {
|
|
5
|
-
const router = express.Router()
|
|
6
|
-
router.use(options.publicPath, express.static(options.fileSystemPath))
|
|
7
|
-
return router
|
|
8
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import { Handler } from 'express'
|
|
3
|
-
import { MiddlewareOptions } from './options'
|
|
4
|
-
import createMiddleware from './createMiddleware'
|
|
5
|
-
import createStaticHost from './createStaticHost'
|
|
6
|
-
|
|
7
|
-
const defaultOptions: MiddlewareOptions = {
|
|
8
|
-
hostStaticAssets: false,
|
|
9
|
-
publicPath: '/public',
|
|
10
|
-
fileSystemPath: path.resolve('./public')
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function init(userOptions: MiddlewareOptions): Handler[] {
|
|
14
|
-
const options: MiddlewareOptions = { ...defaultOptions, ...userOptions }
|
|
15
|
-
|
|
16
|
-
const stack = [createMiddleware(options)]
|
|
17
|
-
|
|
18
|
-
if (options.hostStaticAssets) {
|
|
19
|
-
stack.push(createStaticHost(options))
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return stack
|
|
23
|
-
}
|
package/src/options.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AssetLoaderOptions } from '@financial-times/dotcom-server-asset-loader'
|
|
2
|
-
|
|
3
|
-
export interface MiddlewareOptions extends AssetLoaderOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Set to true if assets should be served from a local directory
|
|
6
|
-
* @default false
|
|
7
|
-
*/
|
|
8
|
-
hostStaticAssets?: boolean
|
|
9
|
-
}
|