Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
try {
cloudinaryAdapter = new CloudinaryAdapter({
...cloudinary,
folder: 'avatars',
});
} catch (e) {
// Downgrade from an error to a warning if the dev does not have a
// Cloudinary API Key set up. This will disable any fields which rely
// on this functionality.
console.warn(e.message);
}
keystone.createList('User', {
fields: {
name: { type: Text },
email: { type: Text, isUnique: true },
dob: {
type: CalendarDay,
import {
Text,
CloudinaryImage,
Integer,
Relationship,
} from '@keystonejs/fields';
import { CloudinaryAdapter } from '@keystonejs/file-adapters';
import { byTracking, atTracking } from '@keystonejs/list-plugins';
const cloudinaryAdapter = new CloudinaryAdapter({
cloudName: process.env.CLOUDINARY_CLOUD_NAME,
apiKey: process.env.CLOUDINARY_KEY,
apiSecret: process.env.CLOUDINARY_SECRET,
folder: 'sick-fits-keystone',
});
export default {
fields: {
name: { type: Text, isRequired: true },
description: { type: Text, isMultiline: true },
image: { type: CloudinaryImage, adapter: cloudinaryAdapter },
largeImage: { type: CloudinaryImage, adapter: cloudinaryAdapter },
price: { type: Integer },
user: {
type: Relationship,
ref: 'User',