Experimental port to Firebase hosting
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
const semver = require('semver');
|
||||
import semver from 'semver';
|
||||
|
||||
const addLeadingSlash = require('../utils/addLeadingSlash');
|
||||
const createPackageURL = require('../utils/createPackageURL');
|
||||
const createSearch = require('../utils/createSearch');
|
||||
const getNpmPackageInfo = require('../utils/getNpmPackageInfo');
|
||||
const incrementCounter = require('../utils/incrementCounter');
|
||||
import addLeadingSlash from '../utils/addLeadingSlash';
|
||||
import createPackageURL from '../utils/createPackageURL';
|
||||
import createSearch from '../utils/createSearch';
|
||||
import getNpmPackageInfo from '../utils/getNpmPackageInfo';
|
||||
// import incrementCounter from '../utils/incrementCounter';
|
||||
|
||||
function tagRedirect(req, res) {
|
||||
const version = req.packageInfo['dist-tags'][req.packageVersion];
|
||||
@ -64,11 +64,11 @@ function filenameRedirect(req, res) {
|
||||
|
||||
// Count which packages are using this so we can warn them when we
|
||||
// remove this functionality.
|
||||
incrementCounter(
|
||||
'package-json-custom-main',
|
||||
req.packageSpec + '?main=' + req.query.main,
|
||||
1
|
||||
);
|
||||
// incrementCounter(
|
||||
// 'package-json-custom-main',
|
||||
// req.packageSpec + '?main=' + req.query.main,
|
||||
// 1
|
||||
// );
|
||||
} else if (
|
||||
req.packageConfig.unpkg &&
|
||||
typeof req.packageConfig.unpkg === 'string'
|
||||
@ -83,7 +83,7 @@ function filenameRedirect(req, res) {
|
||||
|
||||
// Count which packages are using this so we can warn them when we
|
||||
// remove this functionality.
|
||||
incrementCounter('package-json-browser-fallback', req.packageSpec, 1);
|
||||
// incrementCounter('package-json-browser-fallback', req.packageSpec, 1);
|
||||
} else {
|
||||
filename = req.packageConfig.main || '/index.js';
|
||||
}
|
||||
@ -111,7 +111,7 @@ function filenameRedirect(req, res) {
|
||||
* version if the request targets a tag or uses a semver version, or to the
|
||||
* exact filename if the request omits the filename.
|
||||
*/
|
||||
function fetchPackage(req, res, next) {
|
||||
export default function fetchPackage(req, res, next) {
|
||||
getNpmPackageInfo(req.packageName).then(
|
||||
packageInfo => {
|
||||
if (packageInfo == null || packageInfo.versions == null) {
|
||||
@ -149,5 +149,3 @@ function fetchPackage(req, res, next) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = fetchPackage;
|
||||
|
||||
Reference in New Issue
Block a user