Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const MockOEmbedAdapter = require('./mocks/oembed-adapter');
const LOCAL_FILE_SRC = `${staticPath}/avatars`;
const LOCAL_FILE_ROUTE = `${staticRoute}/avatars`;
const Stars = require('./custom-fields/Stars');
const getYear = require('date-fns/get_year');
// TODO: Make this work again
// const SecurePassword = require('./custom-fields/SecurePassword');
const { MongooseAdapter } = require('@keystonejs/adapter-mongoose');
const keystone = new Keystone({
name: 'Cypress Test Project Basic',
adapter: new MongooseAdapter(),
});
const fileAdapter = new LocalFileAdapter({
src: LOCAL_FILE_SRC,
path: LOCAL_FILE_ROUTE,
});
let embedAdapter;
if (process.env.NODE_ENV === 'test') {
embedAdapter = new MockOEmbedAdapter();
} else if (iframely.apiKey) {
embedAdapter = new IframelyOEmbedAdapter({ apiKey: iframely.apiKey });
}
let cloudinaryAdapter;
getImperativeListName,
getDeclarativeListName,
getFieldName,
listAccessVariations,
fieldAccessVariations,
} = require('./cypress/integration/util');
const { port, staticRoute, staticPath } = require('./config');
const initialData = require('./data');
const { MongooseAdapter } = require('@keystonejs/adapter-mongoose');
const keystone = new Keystone({
name: process.env.PROJECT_NAME,
adapter: new MongooseAdapter(),
});
// eslint-disable-next-line no-unused-vars
const authStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: 'User',
});
keystone.createList('User', {
fields: {
email: {
type: Text,
},
password: {
type: Password,
},
const { Keystone } = require('@keystonejs/keystone');
const { PasswordAuthStrategy } = require('@keystonejs/auth-password');
const { Text, Checkbox, Password } = require('@keystonejs/fields');
const { GraphQLApp } = require('@keystonejs/app-graphql');
const { AdminUIApp } = require('@keystonejs/app-admin-ui');
const initialiseData = require('./initial-data');
/* keystone-cli: generated-code */
const { MongooseAdapter: Adapter } = require('@keystonejs/adapter-mongoose');
const PROJECT_NAME = 'My KeystoneJS Project';
/* /keystone-cli: generated-code */
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new Adapter(),
onConnect: initialiseData,
});
// Access control functions
const userIsAdmin = ({ authentication: { item: user } }) => Boolean(user && user.isAdmin);
const userOwnsItem = ({ authentication: { item: user } }) => {
if (!user) {
return false;
}
return { id: user.id };
};
const userIsAdminOrOwner = auth => {
const isAdmin = access.userIsAdmin(auth);
const isOwner = access.userOwnsItem(auth);
return isAdmin ? isAdmin : isOwner;
};
import expressSession from 'express-session';
import MongoStoreMaker from 'connect-mongo';
import Item from './models/Item';
import User from './models/User';
import CartItem from './models/CartItem';
import OrderItem from './models/OrderItem';
import Order from './models/Order';
import { addToCart, checkout, requestReset, resetPassword } from './mutations';
const MongoStore = MongoStoreMaker(expressSession);
const PROJECT_NAME = 'sick-fits-keystone';
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new Adapter(),
// persist logins when the app restarts
sessionStore: new MongoStore({ url: process.env.DATABASE_URL }),
});
keystone.createList('User', User);
keystone.createList('Item', Item);
keystone.createList('CartItem', CartItem);
keystone.createList('OrderItem', OrderItem);
keystone.createList('Order', Order);
const authStrategy = keystone.createAuthStrategy({
type: Auth.PasswordAuthStrategy,
list: 'User',
});
keystone.extendGraphQLSchema({
//imports for Keystone app core
const { Keystone } = require('@keystonejs/keystone');
const { PasswordAuthStrategy } = require('@keystonejs/auth-password');
const { MongooseAdapter } = require('@keystonejs/adapter-mongoose');
const { GraphQLApp } = require('@keystonejs/app-graphql');
const { AdminUIApp } = require('@keystonejs/app-admin-ui');
const { NextApp } = require('@keystonejs/app-next');
const { StaticApp } = require('@keystonejs/app-static');
const { staticRoute, staticPath, distDir } = require('./config');
const { User, Post, PostCategory, Comment } = require('./schema');
const keystone = new Keystone({
name: 'Keystone Demo Blog',
adapter: new MongooseAdapter(),
onConnect: async () => {
// Initialise some data.
// NOTE: This is only for demo purposes and should not be used in production
const users = await keystone.lists.User.adapter.findAll();
if (!users.length) {
const initialData = require('./initialData');
await keystone.createItems(initialData);
}
},
});
const authStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: 'User',
});
const { AdminUI } = require('@keystonejs/admin-ui');
const { Keystone } = require('@keystonejs/core');
const { Text, Password } = require('@keystonejs/fields');
const { WebServer } = require('@keystonejs/server');
const PasswordAuthStrategy = require('@keystonejs/core/auth/Password');
const { port, staticRoute, staticPath } = require('./config');
const initialData = require('./data');
const { MongooseAdapter } = require('@keystonejs/adapter-mongoose');
const keystone = new Keystone({
name: 'Cypress Test Project For Login',
adapter: new MongooseAdapter(),
});
// eslint-disable-next-line no-unused-vars
const authStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: 'User',
});
keystone.createList('User', {
fields: {
name: { type: Text },
email: { type: Text },
password: { type: Password },
},
labelResolver: item => `${item.name} <${item.email}>`,
});
const { Keystone } = require('@keystonejs/keystone');
const { MongooseAdapter } = require('@keystonejs/adapter-mongoose');
const { Text } = require('@keystonejs/fields');
const { GraphQLApp } = require('@keystonejs/app-graphql');
const { AdminUIApp } = require('@keystonejs/app-admin-ui');
const { StaticApp } = require('@keystonejs/app-static');
const keystone = new Keystone({
name: 'Keystone To-Do List',
adapter: new MongooseAdapter(),
});
keystone.createList('Todo', {
schemaDoc: 'A list of things which need to be done',
fields: {
name: { type: Text, schemaDoc: 'This is the thing you need to do', isRequired: true },
},
});
module.exports = {
keystone,
apps: [
new GraphQLApp(),
new StaticApp({ path: '/', src: 'public' }),
// Setup the optional Admin UI
new AdminUIApp({ enableDefaultRoute: true }),
import { MongooseAdapter } from '@keystonejs/adapter-mongoose';
const adapter = new MongooseAdapter();