-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: add middleware
option to Parse Server config
#7942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: alpha
Are you sure you want to change the base?
feat: add middleware
option to Parse Server config
#7942
Conversation
## [5.2.1-alpha.1](parse-community/parse-server@5.2.0...5.2.1-alpha.1) (2022-03-26) ### Bug Fixes * return correct response when revert is used in beforeSave ([parse-community#7839](parse-community#7839)) ([f63fb2b](parse-community@f63fb2b))
… Cloud Function validation (parse-community#7892)
## [5.2.1-alpha.2](parse-community/parse-server@5.2.1-alpha.1...5.2.1-alpha.2) (2022-03-26) ### Performance Improvements * reduce database operations when using the constant parameter in Cloud Function validation ([parse-community#7892](parse-community#7892)) ([48bd512](parse-community@48bd512))
# [5.3.0-alpha.1](parse-community/parse-server@5.2.1-alpha.2...5.3.0-alpha.1) (2022-03-27) ### Features * add MongoDB 5.1 compatibility ([parse-community#7682](parse-community#7682)) ([90155cf](parse-community@90155cf))
# [5.3.0-alpha.2](parse-community/parse-server@5.3.0-alpha.1...5.3.0-alpha.2) (2022-03-27) ### Bug Fixes * security upgrade parse push adapter from 4.1.0 to 4.1.2 ([parse-community#7893](parse-community#7893)) ([ef56e98](parse-community@ef56e98))
# [5.3.0-alpha.3](parse-community/parse-server@5.3.0-alpha.2...5.3.0-alpha.3) (2022-03-27) ### Features * add MongoDB 5.2 support ([parse-community#7894](parse-community#7894)) ([6b4b358](parse-community@6b4b358))
# [5.3.0-alpha.4](parse-community/parse-server@5.3.0-alpha.3...5.3.0-alpha.4) (2022-04-04) ### Bug Fixes * custom database options are not passed to MongoDB GridFS ([parse-community#7911](parse-community#7911)) ([a72b384](parse-community@a72b384))
# [5.3.0-alpha.5](parse-community/parse-server@5.3.0-alpha.4...5.3.0-alpha.5) (2022-04-09) ### Bug Fixes * security upgrade moment from 2.29.1 to 2.29.2 ([parse-community#7931](parse-community#7931)) ([6b68593](parse-community@6b68593))
# [5.3.0-alpha.6](parse-community/parse-server@5.3.0-alpha.5...5.3.0-alpha.6) (2022-04-11) ### Bug Fixes * peer dependency mismatch for GraphQL dependencies ([parse-community#7934](parse-community#7934)) ([b7a1d76](parse-community@b7a1d76))
Thanks for opening this pull request!
|
middleware
option to Parse Server config
# Conflicts: # package-lock.json # package.json
Looks mostly good - might just have to fix lint and tests |
@okobsamoht could you take a look at this PR to get this ready for merging? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed
Come to think of it do you really need const app = express();
app.use(…custom middleware here)
app.use("/parse", new ParseServer(config));
app.listen(1337) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for reply to #7942 (comment)
Hi @dblythy |
i make this quick setup: var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var api = new ParseServer({
appId: "APP_ID",
appNAme: "APP_NAME",
javascriptKey: "JAVASCRIPT_KEY",
masterKey: "MASTER_KEY",
directAccess: true,
enforcePrivateUsers: true,
port: 3000,
mountPath: '/api',
cloud:'cloudCode',
middleware:(req, res, next)=>{
console.log('parse middleware_________________________________________________________________________________')
console.log(req.config)
next()
}
});
var app = express();
app.use((req, res, next)=>{
console.log('express middleware___________________________________________________________________________________')
console.log(req.config)
next()
})
// parse server
app.use('/api', api);
var httpServer = require('http').createServer(app);
httpServer.listen(3000); and each time a ran a request here is the result:
|
Thanks for the explanation! I think this could be solved by #7869 - exposing the config via |
New Pull Request Checklist
Issue Description
the 'middleware' option only works if parse-server is used as command line binary.
when using parse-server as an express middleware the option 'middleware' have no effect.
Approach
i uses the same condition of the middleware in ParseServer.start({...options}, callback) to let parse-server handle the middleware in ParseServer.app({...options})
TODOs before merging