uppy-server
Advanced tools
Comparing version 0.11.1 to 0.11.2
@@ -26,2 +26,3 @@ const Uploader = require('../Uploader'); | ||
endpoint: body.endpoint, | ||
uploadUrl: body.uploadUrl, | ||
protocol: body.protocol, | ||
@@ -28,0 +29,0 @@ metadata: body.metadata, |
@@ -6,2 +6,3 @@ const router = require('express').Router; | ||
acl: 'public-read', | ||
endpoint: 'https://{service}.{region}.amazonaws.com', | ||
conditions: [], | ||
@@ -20,2 +21,3 @@ getKey: (req, filename) => filename | ||
region: config.region, | ||
endpoint: config.endpoint, | ||
accessKeyId: config.key, | ||
@@ -22,0 +24,0 @@ secretAccessKey: config.secret |
@@ -51,2 +51,3 @@ const router = require('express').Router; | ||
endpoint: req.body.endpoint, | ||
uploadUrl: req.body.uploadUrl, | ||
protocol: req.body.protocol, | ||
@@ -53,0 +54,0 @@ metadata: req.body.metadata, |
@@ -13,2 +13,3 @@ const fs = require('fs'); | ||
* @property {string} endpoint | ||
* @property {string=} uploadUrl | ||
* @property {string} protocol | ||
@@ -151,2 +152,3 @@ * @property {object} metadata | ||
endpoint: this.options.endpoint, | ||
uploadUrl: this.options.uploadUrl, | ||
resume: true, | ||
@@ -153,0 +155,0 @@ uploadSize: this.options.size || fs.statSync(this.options.path).size, |
@@ -69,3 +69,3 @@ const request = require('request'); | ||
* @param {boolean} isExternal if the url is for the external world | ||
* @param {boolean} excludeHost if the server domain and protocol should be included | ||
* @param {boolean=} excludeHost if the server domain and protocol should be included | ||
*/ | ||
@@ -72,0 +72,0 @@ const buildURL = (path, isExternal, excludeHost) => { |
const fs = require('fs'); | ||
const merge = require('lodash.merge'); | ||
const stripIndent = require('common-tags/lib/stripIndent'); | ||
const utils = require('../server/utils'); | ||
// @ts-ignore | ||
const { version } = require('../../package.json'); | ||
/** | ||
@@ -40,2 +44,3 @@ * Reads all uppy-server configuration set via environment variables | ||
bucket: process.env.UPPYSERVER_AWS_BUCKET, | ||
endpoint: process.env.UPPYSERVER_AWS_ENDPOINT, | ||
region: process.env.UPPYSERVER_AWS_REGION | ||
@@ -133,1 +138,32 @@ } | ||
}; | ||
exports.buildHelpfulStartupMessage = (uppyOptions) => { | ||
const buildURL = utils.getURLBuilder(uppyOptions); | ||
const callbackURLs = []; | ||
Object.keys(uppyOptions.providerOptions).forEach((providerName) => { | ||
// s3 does not need redirect_uris | ||
if (providerName === 's3') { | ||
return; | ||
} | ||
if (providerName === 'google') { | ||
providerName = 'drive'; | ||
} | ||
callbackURLs.push(buildURL(`/${providerName}/callback`, true)); | ||
}); | ||
return stripIndent ` | ||
Welcome to Uppy Server v${version} | ||
=================================== | ||
Congratulations on setting up Uppy Server! Thanks for joining our cause, you have taken | ||
the first step towards the future of file uploading! We | ||
hope you are as excited about this as we are! | ||
While you did an awesome job on getting Uppy Server running, this is just the welcome | ||
message, so let's talk about the places that really matter: | ||
- Be sure to add ${callbackURLs.join(', ')} as your Oauth redirect uris on their corresponding developer interfaces. | ||
- The URL ${buildURL('/metrics', true)} is available for statistics to keep Uppy Server running smoothly | ||
- https://github.com/transloadit/uppy-server/issues - report your bugs here | ||
So quit lollygagging, start uploading and experience the future! | ||
`; | ||
}; |
@@ -11,8 +11,17 @@ const express = require('express'); | ||
const helper = require('./helper'); | ||
// @ts-ignore | ||
const { version } = require('../../package.json'); | ||
const app = express(); | ||
// for server metrics tracking. | ||
const metricsMiddleware = promBundle({ includeMethod: true, includePath: true }); | ||
const metricsMiddleware = promBundle({ includeMethod: true }); | ||
const promClient = metricsMiddleware.promClient; | ||
const collectDefaultMetrics = promClient.collectDefaultMetrics; | ||
collectDefaultMetrics({ register: promClient.register }); | ||
const promInterval = collectDefaultMetrics({ register: promClient.register, timeout: 5000 }); | ||
// Add version as a prometheus gauge | ||
const versionGauge = new promClient.Gauge({ name: 'uppyserver_version', help: 'npm version as an integer' }); | ||
const numberVersion = version.replace(/\D/g, '') * 1; | ||
versionGauge.set(numberVersion); | ||
if (app.get('env') !== 'test') { | ||
clearInterval(promInterval); | ||
} | ||
// log server requests. | ||
@@ -53,3 +62,4 @@ app.use(morgan('combined')); | ||
sessionOptions.cookie = { | ||
domain: process.env.UPPYSERVER_COOKIE_DOMAIN | ||
domain: process.env.UPPYSERVER_COOKIE_DOMAIN, | ||
maxAge: 24 * 60 * 60 * 1000 // 1 day | ||
}; | ||
@@ -80,9 +90,9 @@ } | ||
}); | ||
const uppyOptions = helper.getUppyOptions(); | ||
// Routes | ||
app.get('/', (req, res) => { | ||
res.setHeader('Content-Type', 'text/plain'); | ||
res.send(['Welcome to Uppy Server', '======================', ''].join('\n')); | ||
res.send(helper.buildHelpfulStartupMessage(uppyOptions)); | ||
}); | ||
// initialize uppy | ||
const uppyOptions = helper.getUppyOptions(); | ||
helper.validateConfig(uppyOptions); | ||
@@ -89,0 +99,0 @@ if (process.env.UPPYSERVER_PATH) { |
@@ -16,2 +16,3 @@ const express = require('express'); | ||
const jobs = require('./server/jobs'); | ||
const interceptor = require('express-interceptor'); | ||
const providers = providerManager.getDefaultProviders(); | ||
@@ -40,2 +41,3 @@ const defaultOptions = { | ||
app.use(cookieParser()); // server tokens are added to cookies | ||
app.use(interceptGrantErrorResponse); | ||
app.use(new Grant(grantConfig)); | ||
@@ -122,2 +124,25 @@ if (options.sendSelfEndpoint) { | ||
}; | ||
// intercepts grantJS' default response error when something goes | ||
// wrong during oauth process. | ||
const interceptGrantErrorResponse = interceptor((req, res) => { | ||
return { | ||
isInterceptable: () => { | ||
// match grant.js' callback url | ||
return /^\/connect\/\w+\/callback/.test(req.path); | ||
}, | ||
intercept: (body, send) => { | ||
const unwantedBody = 'error=Grant%3A%20missing%20session%20or%20misconfigured%20provider'; | ||
if (body === unwantedBody) { | ||
console.error(`uppy-server: grant.js responded with error: ${body}`); | ||
send([ | ||
'Uppy-server was unable to complete the OAuth process :(', | ||
'(Hint, try clearing your cookies and try again)' | ||
].join('\n')); | ||
} | ||
else { | ||
send(body); | ||
} | ||
} | ||
}; | ||
}); | ||
/** | ||
@@ -124,0 +149,0 @@ * returns a logger function, that would log a message only if |
{ | ||
"name": "uppy-server", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "Server component for Uppy's (https://uppy.io) extensible file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Dropbox and Google Drive, S3 and more :dog:", | ||
@@ -63,3 +63,3 @@ "main": "lib/uppy.js", | ||
"supertest": "3.0.0", | ||
"typescript": "^2.6.2" | ||
"typescript": "2.7.1" | ||
}, | ||
@@ -71,5 +71,7 @@ "dependencies": { | ||
"body-parser": "1.18.2", | ||
"common-tags": "^1.7.2", | ||
"connect-redis": "^3.3.0", | ||
"cookie-parser": "1.4.3", | ||
"express": "^4.16.0", | ||
"express-interceptor": "^1.2.0", | ||
"express-prom-bundle": "^3.1.0", | ||
@@ -76,0 +78,0 @@ "express-session": "1.15.6", |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
73297
30
1688
27
39
1
+ Addedcommon-tags@^1.7.2
+ Addedexpress-interceptor@^1.2.0
+ Addedcommon-tags@1.8.2(transitive)
+ Addedexpress-interceptor@1.2.0(transitive)