Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { staticRoute, staticPath, cloudinary, iframely, unsplash } = require('./config');
const { IframelyOEmbedAdapter } = require('@keystonejs/oembed-adapters');
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 });
}
//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',
import { AdminUIApp } from '@keystonejs/app-admin-ui';
import { MongooseAdapter as Adapter } from '@keystonejs/adapter-mongoose';
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',
});
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);
import { Keystone, BaseApp } from '@keystonejs/keystone';
import { PasswordAuthStrategy } from '@keystonejs/auth-password';
import { GraphQLApp } from '@keystonejs/app-graphql';
import { AdminUIApp } from '@keystonejs/app-admin-ui';
import { KnexAdapter as Adapter } from '@keystonejs/adapter-knex';
import { Text, Checkbox, Password, AutoIncrement, CalendarDay, Integer } from '@keystonejs/fields';
import { NextApp } from '@keystonejs/app-next';
import { StaticApp } from '@keystonejs/app-static';
const keystone = new Keystone({
name: 'LiveCorp Backend',
adapter: new Adapter(),
});
keystone.createList('Test', {
fields: {},
access: true,
});
keystone.createList('Test', {
fields: {
autoincrement: { type: AutoIncrement, gqlType: 'ID' },
calendar: {
type: CalendarDay,
format: 'Do MMMM YYYY',
yearRangeFrom: 1901,
yearRangeTo: 2018,
schemaNames = ['testing'],
createLists = () => {},
keystoneOptions,
graphqlOptions = {},
}) {
const Adapter = { mongoose: MongooseAdapter, knex: KnexAdapter }[adapterName];
const argGenerator = {
mongoose: getMongoMemoryServerConfig,
knex: () => ({
dropDatabase: true,
knexOptions: { connection: process.env.KNEX_URI || 'postgres://localhost/keystone' },
}),
}[adapterName];
const keystone = new Keystone({
name,
adapter: new Adapter(await argGenerator()),
defaultAccess: { list: true, field: true },
schemaNames,
...keystoneOptions,
});
createLists(keystone);
const apps = [
new GraphQLApp({
schemaName,
apiPath: '/admin/api',
graphiqlPath: '/admin/graphiql',
apollo: {
tracing: true,
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' }),