我已经使用基于https://realm.io/docs/realm-object-server/latest/index.html#custom-authentication的自定义身份验证更新了index.js文件
下面是我的index.js文件的内容
const RealmObjectServer = require('realm-object-server');
const path = require('path');
const Realm = require('realm');
const server = new RealmObjectServer.BasicServer();
// Update the default path where Realm will be stored.
Realm.defaultPath = './data/realms/MyCustomRealm.realm'
class MyAuthProvider extends RealmObjectServer.auth.AuthProvider {
constructor() {
super();
this.name = 'myAuthProvider';
console.log("Realm default Path = " + Realm.defaultPath)
}
authenticateOrCreateUser(body) {
console.log("In authenticateOrCreateUser with body = ", body)
const userId = body.userId;
return this.service.createOrUpdateUser(
userId,
"myAuthProvider",
false,
null
);
}
}
server.start({
dataPath: path.join(__dirname, '../data'),
authProviders: [ new MyAuthProvider() ],
}).catch((err) => {
console.error("There was an error starting your custom ROS Server", err);
});如何启动服务器以便调用我的"authenticateOrCreateUser“方法?
我尝试了以下操作:
ros start --auth myAuthProvider
ros start --auth MyAuthProvider但得到以下错误:
The auth provider 'myAuthProvider' cannot be found or does not have a default export
The auth provider 'MyAuthProvider' cannot be found or does not have a default export我是javascript的新手,所以不确定默认导出是什么,以及如何添加它?
任何帮助都是非常感谢的。谢谢!
发布于 2017-11-24 18:30:48
尝试使用以下命令启动服务器
npm启动
从您的应用程序目录。
https://stackoverflow.com/questions/47418117
复制相似问题