我无法在 parse-server 中的云代码函数中访问响应 object?

I cannot access to response object in a cloud code function in parse-server?

我搜索了很多,但找不到在 parse-server 云代码中访问云函数响应 object 的方法(我正在使用 parse-server 3.10.0 版)。我错过了什么?

这是每个快递开发者的基本需求。如何添加响应 headers、更改响应状态代码、发送不同的 Content-Type、管道流数据到响应等?

请帮忙。谢谢

这不是云代码功能的目的。如果您想自己处理 express.js request/response 以获得更多自定义用法,您可以将自定义路由或中间件挂载到应用程序。类似于:

const express = require('express');
const ParseServer = require('parse-server').ParseServer;
const app = express();

const api = new ParseServer({
  databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database
  cloud: '/home/myApp/cloud/main.js', // Absolute path to your Cloud Code
  appId: 'myAppId',
  masterKey: 'myMasterKey', // Keep this key secret!
  fileKey: 'optionalFileKey',
  serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed
});

// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

// Any custom middleware that you want as you'd normally do in any Express.js app
app.use('/your-custom-path', yourCustomMidleware);

app.listen(1337, function() {
  console.log('parse-server-example running on port 1337.');
});