Comparing version 1.5.0 to 2.0.0
@@ -7,2 +7,11 @@ # Change Log | ||
## 2.0.0 | ||
_2022-09-19_ | ||
- **BREAKING** chore: Update min node version to 16 | ||
- **BREAKING** chore: Update fastify and other deps to most recent versions | ||
- feat: Make "empty"/meta tokens visible in bundle output | ||
- feat: Report invalid tokens as "invalid", instead of "ignored" (in prod) | ||
## 1.5.0 | ||
@@ -14,3 +23,3 @@ | ||
## 1.4.0 | ||
## 1.4.0 — 1.4.1 | ||
@@ -38,3 +47,3 @@ _2022-02-05_ | ||
- feat: Allow `//` comments inside `@deps` blocks | ||
- docs: Improved README and AppConfig docs. | ||
- docs: Improved README and AppConfig docs | ||
@@ -41,0 +50,0 @@ ## 1.1.3 – 1.1.4 |
{ | ||
"name": "cssserve", | ||
"version": "1.5.0", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@fastify/compress": "^6.1.1", | ||
"@fastify/cors": "^8.1.0", | ||
"@fastify/static": "^6.5.0", | ||
"compression": "^1.7.4", | ||
"fastify": "^2.12.0", | ||
"fastify-compress": "^2.0.1", | ||
"fastify-cors": "^3.0.2", | ||
"fastify-static": "^2.6.0", | ||
"glob": "^7.1.6", | ||
"lru-cache": "^5.1.1", | ||
"fastify": "^4.5.3", | ||
"glob": "^8.0.3", | ||
"lru-cache": "^7.14.0", | ||
"rc": "^1.2.8" | ||
}, | ||
"__devDependencies": { | ||
"@hugsmidjan_is/qj": "^3.5.0" | ||
"@hugsmidjan/qj": "^4.10.2" | ||
}, | ||
@@ -28,4 +28,4 @@ "author": "Hugsmiðjan ehf (http://www.hugsmidjan.is)", | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=16" | ||
} | ||
} |
@@ -15,3 +15,3 @@ # cssserve – CSS Server | ||
- [CSS dependency bundling and version resolution](#css-dependency-bundling-and-version-resolution) | ||
- [Example request](#example-request) | ||
- [Example request](#example-request) | ||
- [Static assets](#static-assets) | ||
@@ -93,4 +93,4 @@ | ||
<link | ||
rel="stylesheet" | ||
href="https://css.server/bundle/v1?m=_base,ModuleB,ModuleA" | ||
rel="stylesheet" | ||
href="https://css.server/bundle/v1?m=_base,ModuleB,ModuleA" | ||
/> | ||
@@ -129,5 +129,5 @@ ``` | ||
@media screen { | ||
.ModuleA { | ||
/* ...styles for ModuleA */ | ||
} | ||
.ModuleA { | ||
/* ...styles for ModuleA */ | ||
} | ||
} | ||
@@ -134,0 +134,0 @@ ``` |
432
server.js
#!/usr/bin/env node | ||
'use strict'; | ||
var fastifyCompress = require('@fastify/compress'); | ||
var fastifyCors = require('@fastify/cors'); | ||
var fastifyStatic = require('@fastify/static'); | ||
var fastify = require('fastify'); | ||
var fastifyCompress = require('fastify-compress'); | ||
var fastifyStatic = require('fastify-static'); | ||
var fastifyCors = require('fastify-cors'); | ||
var fs = require('fs'); | ||
var glob = require('glob'); | ||
var path = require('path'); | ||
var rc = require('rc'); | ||
var LRUCache = require('lru-cache'); | ||
var path = require('path'); | ||
var glob = require('glob'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var fastify__default = /*#__PURE__*/_interopDefaultLegacy(fastify); | ||
var fastifyCompress__default = /*#__PURE__*/_interopDefaultLegacy(fastifyCompress); | ||
var fastifyCors__default = /*#__PURE__*/_interopDefaultLegacy(fastifyCors); | ||
var fastifyStatic__default = /*#__PURE__*/_interopDefaultLegacy(fastifyStatic); | ||
var fastifyCors__default = /*#__PURE__*/_interopDefaultLegacy(fastifyCors); | ||
var fastify__default = /*#__PURE__*/_interopDefaultLegacy(fastify); | ||
var rc__default = /*#__PURE__*/_interopDefaultLegacy(rc); | ||
var LRUCache__default = /*#__PURE__*/_interopDefaultLegacy(LRUCache); | ||
/*! ***************************************************************************** | ||
var name = "cssserve"; | ||
var ensureObject = function (cand) { | ||
if (cand && typeof cand === 'object' && !Array.isArray(cand)) { | ||
return cand; | ||
} | ||
}; | ||
var ensureNonEmptyString = function (cand) { | ||
if (cand && typeof cand === 'string') { | ||
return cand; | ||
} | ||
}; | ||
var ensureStringMap = function (cand) { | ||
var obj = ensureObject(cand); | ||
if (obj && Object.values(obj).every(ensureNonEmptyString)) { | ||
return obj; | ||
} | ||
}; | ||
// --------------------------------------------------------------------------- | ||
var parseRedirects = function (redirects, redirectsFile) { | ||
if (redirects !== undefined) { | ||
redirects = ensureStringMap(redirects); | ||
if (!redirects) { | ||
throw new Error("The redirects config field must contain a string\u2192string map"); | ||
} | ||
} | ||
if (redirectsFile) { | ||
var fileContents = void 0; | ||
try { | ||
fileContents = fs.readFileSync(redirectsFile).toString(); | ||
} | ||
catch (e) { | ||
throw new Error("Could not read redirectsFile \"".concat(redirects, "\"")); | ||
} | ||
var parsedContents = void 0; | ||
try { | ||
parsedContents = JSON.parse(fileContents); | ||
} | ||
catch (e) { | ||
throw new Error("Invalid JSON found in redirectsFile \"".concat(redirects, "\"")); | ||
} | ||
var fileRedirects_1 = ensureStringMap(parsedContents); | ||
if (!fileRedirects_1) { | ||
throw new Error("The redirectsFile \"".concat(redirects, "\" must contain a string\u2192string map")); | ||
} | ||
if (redirects) { | ||
// Merge fileRedirects into redirects. | ||
Object.keys(fileRedirects_1).forEach(function (key) { | ||
redirects[key] = fileRedirects_1[key]; | ||
}); | ||
} | ||
else { | ||
redirects = fileRedirects_1; | ||
} | ||
} | ||
return redirects; | ||
}; | ||
var normalizePathSlash = function (path) { return path.replace(/\/*$/, '/'); }; | ||
var appName = name.split('/').pop(); | ||
var HOUR = 60 * 60; | ||
var defaults = { | ||
port: 4000, | ||
staticFolder: 'public/', | ||
ttl_static: 24 * HOUR, | ||
ttl_bundle: 1 * HOUR, | ||
proxied: false, | ||
cache: true, | ||
loudBadTokenErrors: process.env.NODE_ENV !== 'production', | ||
}; | ||
var config = rc__default["default"](appName, defaults); | ||
// enforce correct types | ||
config.port = parseInt(process.env.NODE_PORT || process.env.PORT || '') || config.port; | ||
config.staticFolder = normalizePathSlash(config.staticFolder.trim()); | ||
config.ttl_static = Number(config.ttl_static); | ||
config.ttl_bundle = Number(config.ttl_bundle); | ||
// config.cacheRefreshToken = | ||
config.cache = Boolean(config.cache); | ||
config.proxied = Boolean(config.proxied); | ||
config.sslKeyPath = config.sslKeyPath && config.sslKeyPath.trim(); | ||
// config.sslCert = | ||
// config.sslPrivkey = | ||
config.loudBadTokenErrors = Boolean(config.loudBadTokenErrors); | ||
config.preload = | ||
config.preload || config.preload === false ? Boolean(config.preload) : true; | ||
config.redirects = parseRedirects(config.redirects, config.redirectsFile); | ||
config.redirectsFile = undefined; | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -42,3 +130,3 @@ | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } }; | ||
function (d, b) { for (var p in b) { if (Object.prototype.hasOwnProperty.call(b, p)) { d[p] = b[p]; } } }; | ||
return extendStatics(d, b); | ||
@@ -48,2 +136,4 @@ }; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
{ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); } | ||
extendStatics(d, b); | ||
@@ -54,56 +144,3 @@ function __() { this.constructor = d; } | ||
// --------------------------------------------------------------------------- | ||
/** | ||
* Checks if an URL token contains no spaces or funny characters. | ||
* Only allows `[a-z0-9-_.]` | ||
*/ | ||
var isSafeToken = function (token) { | ||
return !token || !(/[^a-z0-9-_.]/i.test(token) || /\.\./.test(token)); | ||
}; | ||
var getAllValidCssVersions = function (staticFolder) { | ||
var versions = {}; | ||
var cssFolder = staticFolder + 'css/'; | ||
var versionFolders = glob.sync('*/', { cwd: cssFolder }) | ||
// chop trailing "/" off directoryNames | ||
.map(function (dirName) { return dirName.slice(0, -1); }); | ||
versionFolders.forEach(function (name) { | ||
var superVersions = name | ||
.split('.') | ||
.slice(0, -1) | ||
.reduce(function (superVersions, token, i, arr) { | ||
return superVersions.concat([arr.slice(0, i + 1).join('.')]); | ||
}, []); | ||
superVersions.forEach(function (superVersion) { | ||
if (!versions[superVersion]) { | ||
var cutIdx_1 = superVersion.length + 1; | ||
var topPointVersion = versionFolders | ||
.filter(function (subName) { return subName.startsWith(superVersion + '.'); }) | ||
.map(function (subName) { return subName.slice(cutIdx_1); }) | ||
.filter(function (minorVersionSuffix) { return !/[^0-9.]/.test(minorVersionSuffix); }) | ||
.map(function (minorVersionSuffix) { | ||
var arr = minorVersionSuffix.split('.').map(function (bit) { return parseInt(bit); }); | ||
arr.length = 4; // Normalize the length for saner sort. | ||
return arr; | ||
}) | ||
.sort(function (a, b) { | ||
var idx = a.findIndex(function (_, i) { return a[i] !== b[i]; }); | ||
return (a[idx] || 0) > (b[idx] || 0) ? 1 : -1; | ||
}) | ||
.pop(); | ||
if (topPointVersion) { | ||
var pointVersionSuffix = topPointVersion.join('.').replace(/\.+$/, ''); | ||
versions[superVersion] = 'css/' + superVersion + '.' + pointVersionSuffix + '/'; | ||
} | ||
} | ||
}); | ||
versionFolders.filter(function (fname) { return fname.startsWith(name + '.'); }); | ||
}); | ||
versionFolders.forEach(function (name) { | ||
versions[name] = versions[name] || 'css/' + name + '/'; | ||
}); | ||
return versions; | ||
}; | ||
/** | ||
Add a simple chainable `.on()`, `.off()`, `.emit()` interface to any object. | ||
@@ -223,3 +260,3 @@ | ||
// import eventify from '@hugsmidjan_is/qj/eventify'; | ||
// import eventify from '@hugsmidjan/qj/eventify'; | ||
var _a = eventify({}), on = _a.on, emit = _a.emit; | ||
@@ -233,113 +270,59 @@ var onCacheRefresh = function (callback) { | ||
var name = "cssserve"; | ||
/** | ||
* Compares strings and sorts them by lowercase first | ||
* before doing a normal comparison. | ||
*/ | ||
var lowercaseFirstCompare = function (a, b) { | ||
var aL = a.toLocaleLowerCase(); | ||
var bL = b.toLocaleLowerCase(); | ||
return aL > bL ? 1 : aL < bL ? -1 : a > b ? 1 : -1; | ||
}; | ||
var ensureObject = function (cand) { | ||
if (cand && typeof cand === 'object' && !Array.isArray(cand)) { | ||
return cand; | ||
} | ||
/** | ||
* Returns the value of the first query parameter of a given name | ||
* ...defaulting to an empty string if no parameter is found. | ||
*/ | ||
var getParamArr = function (query, name) { | ||
var val = query[name]; | ||
return val == null ? '' : typeof val === 'string' ? val : val[0]; | ||
}; | ||
var ensureNonEmptyString = function (cand) { | ||
if (cand && typeof cand === 'string') { | ||
return cand; | ||
} | ||
}; | ||
var ensureStringMap = function (cand) { | ||
var obj = ensureObject(cand); | ||
if (obj && Object.values(obj).every(ensureNonEmptyString)) { | ||
return obj; | ||
} | ||
}; | ||
// --------------------------------------------------------------------------- | ||
var parseRedirects = function (redirects, redirectsFile) { | ||
if (redirects !== undefined) { | ||
redirects = ensureStringMap(redirects); | ||
if (!redirects) { | ||
throw new Error("The redirects config field must contain a string\u2192string map"); | ||
} | ||
} | ||
if (redirectsFile) { | ||
var fileContents = void 0; | ||
try { | ||
fileContents = fs.readFileSync(redirectsFile).toString(); | ||
} | ||
catch (e) { | ||
throw new Error("Could not read redirectsFile \"" + redirects + "\""); | ||
} | ||
var parsedContents = void 0; | ||
try { | ||
parsedContents = JSON.parse(fileContents); | ||
} | ||
catch (e) { | ||
throw new Error("Invalid JSON found in redirectsFile \"" + redirects + "\""); | ||
} | ||
var fileRedirects_1 = ensureStringMap(parsedContents); | ||
if (!fileRedirects_1) { | ||
throw new Error("The redirectsFile \"" + redirects + "\" must contain a string\u2192string map"); | ||
} | ||
if (redirects) { | ||
// Merge fileRedirects into redirects. | ||
Object.keys(fileRedirects_1).forEach(function (key) { | ||
redirects[key] = fileRedirects_1[key]; | ||
}); | ||
} | ||
else { | ||
redirects = fileRedirects_1; | ||
} | ||
} | ||
return redirects; | ||
var getModuleListFromQuery = function (query) { | ||
return getParamArr(query, 'm') | ||
.trim() | ||
.split(/\s*,\s*/) | ||
.filter(function (token) { return token; }) | ||
.sort(lowercaseFirstCompare); | ||
}; | ||
var normalizePathSlash = function (path) { return path.replace(/\/*$/, '/'); }; | ||
var appName = name.split('/').pop(); | ||
var HOUR = 60 * 60; | ||
var defaults = { | ||
port: 4000, | ||
staticFolder: 'public/', | ||
ttl_static: 24 * HOUR, | ||
ttl_bundle: 1 * HOUR, | ||
proxied: false, | ||
cache: true, | ||
loudBadTokenErrors: process.env.NODE_ENV !== 'production', | ||
var makeCssFromModuleNames = function (versionFolder, modules) { | ||
return modules | ||
.map(function (moduleName) { | ||
return typeof moduleName === 'string' | ||
? "@import \"/".concat(versionFolder + moduleName, ".css\";\n") | ||
: moduleName.invalid | ||
? "/* token ".concat(JSON.stringify(moduleName.name), " is invalid */\n") | ||
: "/* token ".concat(JSON.stringify(moduleName.name), " has no CSS */\n"); | ||
}) | ||
.join(''); | ||
}; | ||
var config = rc__default["default"](appName, defaults); | ||
// enforce correct types | ||
config.port = parseInt(process.env.NODE_PORT || process.env.PORT || '') || config.port; | ||
config.staticFolder = normalizePathSlash(config.staticFolder.trim()); | ||
config.ttl_static = Number(config.ttl_static); | ||
config.ttl_bundle = Number(config.ttl_bundle); | ||
// config.cacheRefreshToken = | ||
config.cache = Boolean(config.cache); | ||
config.proxied = Boolean(config.proxied); | ||
config.sslKeyPath = config.sslKeyPath && config.sslKeyPath.trim(); | ||
// config.sslCert = | ||
// config.sslPrivkey = | ||
config.loudBadTokenErrors = Boolean(config.loudBadTokenErrors); | ||
config.preload = | ||
config.preload || config.preload === false ? Boolean(config.preload) : true; | ||
config.redirects = parseRedirects(config.redirects, config.redirectsFile); | ||
config.redirectsFile = undefined; | ||
var _validVersions = {}; | ||
onCacheRefresh(function () { | ||
_validVersions = {}; | ||
}); | ||
var resolveCssVersionFolder = function (staticFolder, versionParam) { | ||
if (!versionParam || !isSafeToken(versionParam)) { | ||
return null; | ||
} | ||
var versions = config.cache && _validVersions[staticFolder]; | ||
if (!versions) { | ||
versions = _validVersions[staticFolder] = getAllValidCssVersions(staticFolder); | ||
} | ||
return versions[versionParam] || null; | ||
var makeLinkHeaderValue = function (versionFolder, modules) { | ||
return modules | ||
.filter(function (moduleName) { return typeof moduleName === 'string'; }) | ||
.map(function (moduleName) { return "</".concat(versionFolder + moduleName, ".css>;rel=preload;as=style"); }) | ||
.join(',') || undefined; | ||
}; | ||
var isProd = process.env.NODE_ENV === 'production'; | ||
var isDebug = process.env.NODE_ENV === 'debug'; | ||
var isDev = isDebug || process.env.NODE_ENV === 'development'; | ||
// --------------------------------------------------------------------------- | ||
/** | ||
* Compares strings and sorts them by lowercase first | ||
* before doing a normal comparison. | ||
* Checks if an URL token contains no spaces or funny characters. | ||
* Only allows `[a-z0-9-_.]` | ||
*/ | ||
var lowercaseFirstCompare = function (a, b) { | ||
var aL = a.toLocaleLowerCase(); | ||
var bL = b.toLocaleLowerCase(); | ||
return aL > bL ? 1 : aL < bL ? -1 : a > b ? 1 : -1; | ||
var isSafeToken = function (token) { | ||
return !token || !(/[^a-z0-9-_.]/i.test(token) || /\.\./.test(token)); | ||
}; | ||
@@ -369,6 +352,2 @@ | ||
var isProd = process.env.NODE_ENV === 'production'; | ||
var isDebug = process.env.NODE_ENV === 'debug'; | ||
var isDev = isDebug || process.env.NODE_ENV === 'development'; | ||
// --------------------------------------------------------------------------- | ||
@@ -467,3 +446,3 @@ var NotFoundError = /** @class */ (function (_super) { | ||
} | ||
return list.concat({ ignored: moduleName }); | ||
return list.concat({ name: moduleName, invalid: true }); | ||
} | ||
@@ -473,3 +452,5 @@ found[moduleName] = true; | ||
var deps = getDepsFor(contextFile, opts.cache); | ||
return deps.reduce(parseDepsTree, list).concat(deps.hasCSS ? [moduleName] : []); | ||
return deps | ||
.reduce(parseDepsTree, list) | ||
.concat(deps.hasCSS ? [moduleName] : [{ name: moduleName, empty: true }]); | ||
}; | ||
@@ -481,36 +462,61 @@ modules = modules.slice(0).sort(lowercaseFirstCompare); | ||
/** | ||
* Returns the value of the first query parameter of a given name | ||
* ...defaulting to an empty string if no parameter is found. | ||
*/ | ||
var getParamArr = function (query, name) { | ||
var val = query[name]; | ||
return val == null ? '' : typeof val === 'string' ? val : val[0]; | ||
var getAllValidCssVersions = function (staticFolder) { | ||
var versions = {}; | ||
var cssFolder = staticFolder + 'css/'; | ||
var versionFolders = glob.sync('*/', { cwd: cssFolder }) | ||
// chop trailing "/" off directoryNames | ||
.map(function (dirName) { return dirName.slice(0, -1); }); | ||
versionFolders.forEach(function (name) { | ||
var superVersions = name | ||
.split('.') | ||
.slice(0, -1) | ||
.reduce(function (superVersions, token, i, arr) { | ||
return superVersions.concat([arr.slice(0, i + 1).join('.')]); | ||
}, []); | ||
superVersions.forEach(function (superVersion) { | ||
if (!versions[superVersion]) { | ||
var cutIdx_1 = superVersion.length + 1; | ||
var topPointVersion = versionFolders | ||
.filter(function (subName) { return subName.startsWith(superVersion + '.'); }) | ||
.map(function (subName) { return subName.slice(cutIdx_1); }) | ||
.filter(function (minorVersionSuffix) { return !/[^0-9.]/.test(minorVersionSuffix); }) | ||
.map(function (minorVersionSuffix) { | ||
var arr = minorVersionSuffix.split('.').map(function (bit) { return parseInt(bit); }); | ||
arr.length = 4; // Normalize the length for saner sort. | ||
return arr; | ||
}) | ||
.sort(function (a, b) { | ||
var idx = a.findIndex(function (_, i) { return a[i] !== b[i]; }); | ||
return (a[idx] || 0) > (b[idx] || 0) ? 1 : -1; | ||
}) | ||
.pop(); | ||
if (topPointVersion) { | ||
var pointVersionSuffix = topPointVersion.join('.').replace(/\.+$/, ''); | ||
versions[superVersion] = 'css/' + superVersion + '.' + pointVersionSuffix + '/'; | ||
} | ||
} | ||
}); | ||
versionFolders.filter(function (fname) { return fname.startsWith(name + '.'); }); | ||
}); | ||
versionFolders.forEach(function (name) { | ||
versions[name] = versions[name] || 'css/' + name + '/'; | ||
}); | ||
return versions; | ||
}; | ||
// --------------------------------------------------------------------------- | ||
var getModuleListFromQuery = function (query) { | ||
return getParamArr(query, 'm') | ||
.trim() | ||
.split(/\s*,\s*/) | ||
.filter(function (token) { return token; }) | ||
.sort(lowercaseFirstCompare); | ||
}; | ||
var makeLinkHeaderValue = function (versionFolder, modules) { | ||
return modules | ||
.filter(function (moduleName) { return typeof moduleName === 'string'; }) | ||
.map(function (moduleName) { return "</" + (versionFolder + moduleName) + ".css>;rel=preload;as=style"; }) | ||
.join(',') || undefined; | ||
var _validVersions = {}; | ||
onCacheRefresh(function () { | ||
_validVersions = {}; | ||
}); | ||
var resolveCssVersionFolder = function (staticFolder, versionParam) { | ||
if (!versionParam || !isSafeToken(versionParam)) { | ||
return null; | ||
} | ||
var versions = config.cache && _validVersions[staticFolder]; | ||
if (!versions) { | ||
versions = _validVersions[staticFolder] = getAllValidCssVersions(staticFolder); | ||
} | ||
return versions[versionParam] || null; | ||
}; | ||
var makeCssFromModuleNames = function (versionFolder, modules) { | ||
return modules | ||
.map(function (moduleName) { | ||
return typeof moduleName === 'string' | ||
? "@import \"/" + (versionFolder + moduleName) + ".css\";\n" | ||
: "/* token " + JSON.stringify(moduleName.ignored) + " ignored */\n"; | ||
}) | ||
.join(''); | ||
}; | ||
var ttl_bundle = config.ttl_bundle, staticFolder$1 = config.staticFolder, cacheRefreshToken = config.cacheRefreshToken, cache = config.cache, loudBadTokenErrors = config.loudBadTokenErrors, preload = config.preload; | ||
@@ -544,3 +550,3 @@ var CACHE_CONTROL_VALUE = 'public, max-age=' + ttl_bundle + (ttl_bundle ? ', immutable' : ''); | ||
.then(function () { | ||
var url = req.req.url; | ||
var url = req.raw.url; | ||
var cachedBundle = bundleCache.get(url); | ||
@@ -601,3 +607,3 @@ if (cachedBundle) { | ||
var cssBundler = function (req, res) { | ||
var browserEtag = req.headers['If-None-Match']; | ||
var browserEtag = Number(req.headers['If-None-Match']) || 0; | ||
if (browserEtag >= lastModified) { | ||
@@ -662,3 +668,3 @@ res | ||
if (ttl !== null) { | ||
res.header('Cache-Control', "public, max-age=" + ttl + ", immutable"); | ||
res.header('Cache-Control', "public, max-age=".concat(ttl, ", immutable")); | ||
} | ||
@@ -675,5 +681,5 @@ res.status(status).send(''); | ||
var sslKeyPath = config.sslKeyPath || __dirname + '/default-keys/'; | ||
var app = fastify__default["default"](proxied | ||
? {} | ||
: { | ||
var app = proxied | ||
? fastify__default["default"]({}) | ||
: fastify__default["default"]({ | ||
http2: true, | ||
@@ -687,3 +693,3 @@ https: { | ||
if (!proxied) { | ||
app.register(fastifyCompress__default["default"], { global: true }); | ||
app.register(fastifyCompress__default["default"]); | ||
} | ||
@@ -701,3 +707,3 @@ app.register(fastifyCors__default["default"], { | ||
// lastModified: false, | ||
etag: false, | ||
etag: false, // Auto-generated from the file's modification date. | ||
}); | ||
@@ -713,10 +719,12 @@ app.setNotFoundHandler(function (req, res) { | ||
app.get('/bundle/:version', cssBundler); | ||
app.listen(port, '0.0.0.0', function (err) { | ||
app | ||
.listen({ port: port }) | ||
.then(function () { | ||
var protocol = proxied ? 'http' : 'https'; | ||
console.info('CSS server listening on ' + protocol + '://localhost:' + port); | ||
}) | ||
.catch(function (err) { | ||
if (err) { | ||
console.error(err); | ||
} | ||
else { | ||
var protocol = proxied ? 'http' : 'https'; | ||
console.info('CSS server listening on ' + protocol + '://localhost:' + port); | ||
} | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35373
671
+ Added@fastify/compress@^6.1.1
+ Added@fastify/cors@^8.1.0
+ Added@fastify/static@^6.5.0
+ Added@fastify/accept-negotiator@1.1.0(transitive)
+ Added@fastify/ajv-compiler@3.6.0(transitive)
+ Added@fastify/compress@6.5.0(transitive)
+ Added@fastify/cors@8.5.0(transitive)
+ Added@fastify/error@3.4.1(transitive)
+ Added@fastify/fast-json-stringify-compiler@4.3.0(transitive)
+ Added@fastify/merge-json-schemas@0.1.1(transitive)
+ Added@fastify/send@2.1.0(transitive)
+ Added@fastify/static@6.12.0(transitive)
+ Added@lukeed/ms@2.0.2(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedajv@8.17.1(transitive)
+ Addedajv-formats@2.1.13.0.1(transitive)
+ Addedavvio@8.4.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedcookie@0.6.0(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfast-content-type-parse@1.1.0(transitive)
+ Addedfast-json-stringify@5.16.1(transitive)
+ Addedfast-querystring@1.1.2(transitive)
+ Addedfast-redact@3.5.0(transitive)
+ Addedfast-uri@2.4.03.0.2(transitive)
+ Addedfastify@4.28.1(transitive)
+ Addedfastify-plugin@4.5.1(transitive)
+ Addedfind-my-way@8.2.2(transitive)
+ Addedglob@8.1.0(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinto-stream@6.0.0(transitive)
+ Addedjson-schema-ref-resolver@1.0.1(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedlight-my-request@5.13.0(transitive)
+ Addedlru-cache@7.18.3(transitive)
+ Addedmime@3.0.0(transitive)
+ Addedminimatch@5.1.6(transitive)
+ Addedminipass@7.1.2(transitive)
+ Addedmnemonist@0.39.6(transitive)
+ Addedobliterator@2.0.4(transitive)
+ Addedon-exit-leak-free@2.1.2(transitive)
+ Addedp-is-promise@3.0.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedpino@9.4.0(transitive)
+ Addedpino-abstract-transport@1.2.0(transitive)
+ Addedpino-std-serializers@7.0.0(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-warning@3.0.04.0.0(transitive)
+ Addedquick-format-unescaped@4.0.4(transitive)
+ Addedreadable-stream@4.5.2(transitive)
+ Addedreal-require@0.2.0(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
+ Addedret@0.4.3(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafe-regex2@3.1.0(transitive)
+ Addedsafe-stable-stringify@2.5.0(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedsonic-boom@4.1.0(transitive)
+ Addedsplit2@4.2.0(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedthread-stream@3.1.0(transitive)
+ Addedtoad-cache@3.7.0(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removedfastify-compress@^2.0.1
- Removedfastify-cors@^3.0.2
- Removedfastify-static@^2.6.0
- Removedajv@6.12.6(transitive)
- Removedarchy@1.0.0(transitive)
- Removedavvio@6.5.0(transitive)
- Removedbig-integer@1.6.52(transitive)
- Removedbinary@0.3.0(transitive)
- Removedbluebird@3.4.7(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbuffer-indexof-polyfill@1.0.2(transitive)
- Removedbuffers@0.1.1(transitive)
- Removedchainsaw@0.1.0(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcookie@0.4.2(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddeepmerge@4.3.1(transitive)
- Removeddepd@1.1.2(transitive)
- Removeddestroy@1.0.4(transitive)
- Removedduplexer2@0.1.4(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.2(transitive)
- Removedencoding-negotiator@2.0.1(transitive)
- Removedetag@1.8.1(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfast-json-stringify@1.21.0(transitive)
- Removedfast-redact@2.1.0(transitive)
- Removedfast-safe-stringify@2.1.1(transitive)
- Removedfastify@2.15.3(transitive)
- Removedfastify-compress@2.0.1(transitive)
- Removedfastify-cors@3.0.3(transitive)
- Removedfastify-plugin@1.6.1(transitive)
- Removedfastify-static@2.7.0(transitive)
- Removedfind-my-way@2.2.5(transitive)
- Removedflatstr@1.0.12(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfstream@1.0.12(transitive)
- Removedglob@7.2.3(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhttp-errors@1.6.3(transitive)
- Removedinherits@2.0.3(transitive)
- Removedinto-stream@4.0.0(transitive)
- Removedis-deflate@1.0.0(transitive)
- Removedis-gzip@1.0.0(transitive)
- Removedis-stream@2.0.1(transitive)
- Removedis-zip@1.0.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedlight-my-request@3.8.0(transitive)
- Removedlistenercount@1.0.1(transitive)
- Removedlru-cache@5.1.1(transitive)
- Removedmiddie@4.1.0(transitive)
- Removedmime@1.4.1(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminipass@2.9.0(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.1.3(transitive)
- Removedon-finished@2.3.0(transitive)
- Removedp-is-promise@2.1.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-to-regexp@4.0.5(transitive)
- Removedpino@5.17.0(transitive)
- Removedpino-std-serializers@2.5.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedquick-format-unescaped@3.0.3(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedret@0.2.2(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedsafe-regex2@2.0.0(transitive)
- Removedsemver@6.3.1(transitive)
- Removedsemver-store@0.3.0(transitive)
- Removedsend@0.16.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedsetprototypeof@1.1.0(transitive)
- Removedsonic-boom@0.7.7(transitive)
- Removedstatuses@1.4.0(transitive)
- Removedstring-similarity@4.0.4(transitive)
- Removedstring-to-stream@3.0.1(transitive)
- Removedtiny-lru@7.0.6(transitive)
- Removedtraverse@0.3.9(transitive)
- Removedunzipper@0.10.14(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedyallist@3.1.1(transitive)
Updatedfastify@^4.5.3
Updatedglob@^8.0.3
Updatedlru-cache@^7.14.0