
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
parse-server-cloud-middleware
Advanced tools
Are you looking for something like this: ```js Parse.Cloud.define('doSomethingA', UserModule.doSomethingA, ['checkVersion', 'validateActiveUser']); Parse.Cloud.define('doAnotherThingB', UserModule.doAnotherThingB, ['checkVersion', 'onlyAdmin', 'logRequest
Are you looking for something like this:
Parse.Cloud.define('doSomethingA', UserModule.doSomethingA, ['checkVersion', 'validateActiveUser']);
Parse.Cloud.define('doAnotherThingB', UserModule.doAnotherThingB, ['checkVersion', 'onlyAdmin', 'logRequest']);
Support Application-level middleware, middleware must be a custom middleware and following Usage part. This plugin is NOT compatible with expressJS style middleware.
First, require the package only once, before defining cloud functions
require('parse-server-cloud-middleware');
Then, you can now pass an Array of middleware function as third param of Parse.Cloud.define
Parse.Cloud.define('doSomethingA', UserModule.doSomethingA, [checkVersion, validateActiveUser]);
Unlike expressJS middleware style which is required to use next() function, a Parse middleware function can be written similar to a Cloud function, it has request
object.
You can:
request
so next middlewares and main Cloud function can access to that information.const validateActiveUser = (request) => {
const user = request.user;
if (!user || user.get('status') !== 'ACTIVE') {
throw new Parse.Error(403, 'FORBIDDEN')
}
};
const checkVersion = (request) => {
const { version } = request.params;
if (!version) {
throw new Error('missing version'); // new Parse.Error
}
if (version !== '1.1.1') {
throw new Error('this cloud function is only for version 1.1.1') // new Parse.Error
}
};
const withCachedMiddleware = async (request, response) => {
const cachedData = cacheProvider.key(request.params.sample)
if (cachedData.exists()) {
return response(await cachedData.fetch()); // this is the end, main cloud function won't be reached.
}
return; // enter main cloud function, responded by main cloud function result
};
response
as function. You can also use response
similar to legacy style Parse server 2.x.x:return response(await cachedData.fetch());
return response.success(await cachedData.fetch());
return response.error(); // Using "throw" statement is better than response.error()
It's basically the same, but you can inject the middleware function name-string instead!
const { init } = require('parse-server-cloud-middleware');
const MiddleWares = {
checkVersion: require('./middlewares/checkVersion'),
validateActiveUser: userModule.validateActiveUserMiddleware,
}
init(MiddleWares);
Parse.Cloud.define('doSomethingA', UserModule.doSomethingA, ['checkVersion', 'validateActiveUser']);
FAQs
Are you looking for something like this: ```js Parse.Cloud.define('doSomethingA', UserModule.doSomethingA, ['checkVersion', 'validateActiveUser']); Parse.Cloud.define('doAnotherThingB', UserModule.doAnotherThingB, ['checkVersion', 'onlyAdmin', 'logRequest
The npm package parse-server-cloud-middleware receives a total of 4 weekly downloads. As such, parse-server-cloud-middleware popularity was classified as not popular.
We found that parse-server-cloud-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.