Tag: keystonejs

如何让特定的服务器访问我的API?

我正在编写一个API,使用node.js,express和mongodb,这将在另一个服务器中使用。 我只希望只有那个服务器(或者将来更多)能够访问我的API。 我怎样才能做到这一点?

多对多的关系 – 填充查询中的相关数据 – Keystonejs

我正在研究一个keystonejs项目,并遇到两个模型之间的关系问题。 我有以下两种模式: 用户型号: User.add({ name: { type: Types.Name, required: true, index: true }, email: { type: Types.Email, initial: true, required: true, index: true }, number: { type: Types.Number, index: true }, password: { type: Types.Password, initial: true, required: true } }, 'Permissions', { isAdmin: { type: Boolean, label: 'Can access Keystone', index: true }, }, […]

一旦特定型号更新,我如何获得keystoneJS运行function?

我想要在特定的KeystoneJS模型中有新的或更新的项目时运行一个函数。 我怎么做? 我会添加一个事件…是否有事件? 添加到模型或其他地方吗?

使用UpdateHandler在Keystone.js中上传LocalFile

怎么会这样做呢? 在这里 ,有人build议在profileImage._.uploadImage(file, update, callback)使用UpdateHandler或列表项的下划线方法来处理file upload,但它们使用S3 File而不是LocalFile 。 首先尝试使用下划线方法,但似乎不像上述问题那样工作。 在其他网站上有很多分散的文档,但都显得过时(有些人build议使用不再存在的LocalFile方法),并包含许多断开的链接。 查看js(中间件)代码: view.on('post', { action: 'edit-profile' }, next => { let updater = locals.user.getUpdateHandler(req, res, { errorMessage: 'There was an error editing your profile:' }); updater.process(req.body, { flashErrors: true, logErrors: true, fields: 'profileImage, email, name, password' }, err => { if (err) { locals.validationErrors = err.errors; […]

Mongoose / keystonejs:唯一字段,除非字段为空

我有一个电子邮件字段,我想要独特的电子邮件。 我也想有一个空的领域的可能性。 如果电子邮件为空/空/不存在,我不希望它检查唯一性。 这是我在Keystone中定义的列表模式: Book.add({ number: { type: Types.Number }, email: { type: Types.Email, initial: true, index: true, unique: true }, token: { type: Types.Text }, title: { type: Types.Text, initial: true }, author: { type: Types.Text, initial: true }, name: { type: Types.Text, initial: true }, dedication: { type: Types.Textarea, initial: true }, image: […]

Keystone.js自签名证书

我正在尝试运行带有自签名SSL证书的Keystone.js。 工作不正常 Fri, 22 Jul 2016 06:36:57 GMT uncaughtException: self signed certificate Error: self signed certificate at Error (native) at TLSSocket.<anonymous> (_tls_wrap.js:1057:38) at emitNone (events.js:67:13) at TLSSocket.emit (events.js:166:7) at TLSSocket._finishInit (_tls_wrap.js:596:8) Mongoose接受一个参数sslValidate = false。 无论如何要通过Keystone?

从Cloudinary切换到S3 – 无法上传

我有一个KeystoneJS项目,将从Cloudinary切换到S3。 该项目与Cloudinary开箱即用。 但是,我们想迁移到使用S3进行存储。 我目前有S3在我的keystone.js文件中设置: var config = require('./config.json'); keystone.set('s3 config', { bucket: config.s3.bucket, key: config.s3.key, secret: config.s3.secret }); 我有另一个叫做Page模型,我想用上传图片。 有一个名为heroImage的字段,以前是一个简单的{ type: Types.Cloudinary } 但是,为了使用S3,我必须将其更改为: heroImage: { type: Types.S3File, format: function(item, file) { return '<img src="' + file.url + '" style="max-width: 300px">'; } } 进入AdminUI时,一切都很好。 我可以点击Upload File ,按下Save ,我收到一条成功消息。 我用传输检查了S3存储桶,发现这个文件从未上传过。 另外,去文件URL显示这个: <Error> <Code>PermanentRedirect</Code> <Message> The bucket […]

validation在Keystone.js中相互依赖的字段

我正在尝试在保存项目时进行validation。 这是我的削减模型: Sample.add({ isPublished: { type: Types.Boolean, default: false }, thumbnailImage: { type: Types.CloudinaryImage, folder: 'samples/thumbnails' }, }); Sample.schema.pre('validate', function(next) { if (this.isPublished && !(_.isEmpty(this.thumbnailImage.image))) { next('Thumbnail Image is required when publishing a sample'); } else { next(); } }); 如果Sample模型的isPublished设置为true但是没有设置thumbnailImage我想引发一个错误。 当我console.log()的值,我分别看到true和false ,但在Keystone Admin中没有发生validation错误。 我已经通过Github上的示例应用程序了解了Keystone,Mongoose文档有很多示例,但是我没有看到任何处理多个文档path的示例。 例如: mongoose自定义validation使用2个字段 (目前有12个upvotes)也不适合我。 我究竟做错了什么? 我正在使用Mongoose 3.8.35。

如何将自定义插件添加到KeystoneJSpipe理界面?

有没有一种方法可以将自定义插件添加到KeystoneJs Admin UI,而不会太多地干扰源代码。

Keystone:将mongoose链接传送到Keystone选项

查看文档,可以将一个Mongoose实例传递给Keystone选项: http://keystonejs.com/docs/configuration/ “mongoose对象:用来代替默认实例的Mongoose实例” 但是怎么…? 我如何从Mongoose中获取实例?