Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.addRoutes = function (keystoneList, methods, middleware, relationships) {
// Get reference to mongoose for internal use
mongoose = keystone.mongoose;
var findBy;
var Model = keystoneList.model;
if (!Model instanceof mongoose.model) { throw new Error('keystoneList is required'); }
if (!methods) { throw new Error('Methods are required'); }
if (!mongoose) { throw new Error('Keystone must be initialized before attempting to add routes'); }
var selected = _getSelected(Model.schema),
uneditable = _getUneditable(Model.schema),
listMiddleware,
showMiddleware,
createMiddleware,
updateMiddleware,
deleteMiddleware;
#!/bin/sh
':' //# http://sambal.org/?p=1014; exec /usr/bin/env node --require babel-polyfill $0 $@
var config = require('/opt/cocorico/api-web/config.json');
var keystone = require('keystone');
var argv = require('minimist')(process.argv.slice(2));
keystone.init({mongo: config.mongo.uri, headless: true});
keystone.mongoose.connect(config.mongo.uri);
keystone.import('../dist/models');
var App = keystone.list('App');
function addApp(title, secret, url, done) {
App.model.findOne({title: title})
.exec((err, app) => {
if (err) {
return done(err);
}
if (!app) {
var newApp = new App.model({
title: title,
secret: secret,
validURLs: [url],
#!/bin/sh
':' //# http://sambal.org/?p=1014; exec /usr/bin/env node --require babel-polyfill $0 $@
var config = require('/opt/cocorico/api-web/config.json');
var keystone = require('keystone');
var fs = require('fs');
var async = require('async');
var argv = require('minimist')(process.argv.slice(2));
keystone.init({mongo: config.mongo.uri, headless: true});
keystone.mongoose.connect(config.mongo.uri);
keystone.import('../dist/models');
var IPAddress = keystone.list('IPAddress');
var ips = fs.readFileSync(argv.file).toString().split('\n').filter(e=>!!e);
async.waterfall(
ips.map((ip) => (callback) => {
IPAddress.model.findOne({ip:ip}).exec((err, address) => {
if (!!err) {
callback(err);
}
if (!address) {
address = IPAddress.model({ip:ip});
}
function getDatabaseStatus() {
return keystone.mongoose.connection.readyState !== 0;
}
var keystone = require('keystone');
var _ = require('lodash');
var restful = require("restful-keystone")(keystone, {
root: process.env.API_BASE || "/api/"
});
var models = Object.keys(keystone.mongoose.models);
module.exports = function(){
return restful.expose(_.reduce(models, (memo,model,i) => {
memo[model] = true;
return memo;
},{}))
.start();
}();
var keystone = require('keystone');
var async = require('async');
var transform = require('model-transform');
var bcrypt = require('bcrypt');
var deepPopulate = require('mongoose-deep-populate')(keystone.mongoose);
var Types = keystone.Field.Types;
var Bill = new keystone.List('Bill', {
autokey: { path: 'slug', from: 'title', unique: true },
map: { name: 'title' },
defaultSort: '-createdAt'
});
Bill.add({
title: { type: String, required: true },
createdAt: { type: Date, default: Date.now },
publishedAt: Date,
content: { type: Types.Markdown, wysiwyg: true, height: 400 },
author: { type: String, required: true, initial: true },
status: { type: Types.Select, options: ['draft', 'review', 'debate', 'vote', 'published'], default: 'draft' },