
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
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
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
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.