<commit_before>var config 	 	= require('../config.js').s3;
var mongoose 	= require('mongoose');
var crate 		= require('mongoose-crate');
var S3 			= require('mongoose-crate-s3');
var ImageMagick = require('mongoose-crate-imagemagick');
var Schema 		= mongoose.Schema;
var ObjectId 	= mongoose.Schema.Types.ObjectId;


var designSchema = new Schema({
	designerUserName: 	{type: String, required: true, unique: true},
	designerId: 		{type: ObjectId, required: true, unique: true},
	name: 				{type: String, required: true},
	description: 		{type: String, required: true},
	dateAdded: 			{type: Date, required: true}
});

designSchema.plugin(crate, {
	storage: new S3({
		key: config.key,
		secret: config.secret,
		bucket: config.bucket,
		acl: config.acl,
		region: config.region,
	}),
	fields: {
		designMainImage: {
			processor: new ImageMagick({
				// tmpDir: '/tmp', // Where transformed files are placed before storage, defaults to os.tmpdir()
				// formats: ['JPEG', 'GIF', 'PNG'], // Supported formats, defaults to ['JPEG', 'GIF', 'PNG', 'TIFF']
				transforms: {
					original: {
						// keep the original file
					},
					small: {
						resize: '200x200',
						format: '.jpg'
					},
					medium: {
						resize: '300x300',
						format: '.jpg'
					},
					large: {
						resize: '500x500',
						format: '.jpg'
					},
					extraLarge: {
						resize: '1000x1000',
						format: '.jpg'
					}
				}
			})
		},
		designAdditionalImages: {
			array: true,
			processor: new ImageMagick({
				// tmpDir: '/tmp', // Where transformed files are placed before storage, defaults to os.tmpdir()
				// formats: ['JPEG', 'GIF', 'PNG'], // Supported formats, defaults to ['JPEG', 'GIF', 'PNG', 'TIFF']
				transforms: {
					original: {
						// keep the original file
					},
					small: {
						resize: '200x200',
						format: '.jpg'
					},
					medium: {
						resize: '300x300',
						format: '.jpg'
					},
					large: {
						resize: '500x500',
						format: '.jpg'
					},
					extraLarge: {
						resize: '1000x1000',
						format: '.jpg'
					}
				}
			})
		}
	}
});


var userSchema = new Schema({
	username: 		{type: String, required: true, unique: true},
	email: 			{type: String, required: true, unique: true},
	firstName: 		{type: String, required: true},
	surname: 		{type: String, required: true},
	phoneNumber: 	{type: String}, //optional --NB. must make sure phone/address kept private, admin use only
	address: 		{type: String}, //optional
	bio: 			{type: String}, //optional
	links: 			[String], 		//optional
	dateJoined: 	{type: Date, required: true},
	isAdmin: 		{type: Boolean, required: true, default: false},
	// isDesigner	{type: Boolean, required: true, default: false}, //if taking user signups, e.g. to preorder
	designIds: 		[ObjectId]
});


userSchema.plugin(crate, {
	storage: new S3({
		key: config.key,
		secret: config.secret,
		bucket: config.bucket,
		acl: config.acl,
		region: config.region,
	}),
	fields: {
		profileImage: {
			processor: new ImageMagick({
				// tmpDir: '/tmp', // Where transformed files are placed before storage, defaults to os.tmpdir()
				// formats: ['JPEG', 'GIF', 'PNG'], // Supported formats, defaults to ['JPEG', 'GIF', 'PNG', 'TIFF']
				transforms: {
					original: {
						// keep the original file
					},
					small: {
						resize: '200x200',
						format: '.jpg'
					},
					medium: {
						resize: '300x300',
						format: '.jpg'
					},
					large: {
						resize: '500x500',
						format: '.jpg'
					}
				}
			})
		},
		additionalFiles: {
			array: true
		}
	}
});

var User 	= mongoose.model('user', userSchema, 'users');
var Design 	= mongoose.model('design', designSchema, 'designs');

module.exports= {
	User: User,
	Design: Design
};
<commit_msg>create user and profile view controllers<commit_after>var config 	 	= require('../config.js').s3;
var mongoose 	= require('mongoose');
var crate 		= require('mongoose-crate');
var S3 			= require('mongoose-crate-s3');
var ImageMagick = require('mongoose-crate-imagemagick');
var Schema 		= mongoose.Schema;
var ObjectId 	= mongoose.Schema.Types.ObjectId;


var designSchema = new Schema({
	designerUserName: 	{type: String, required: true, unique: true},
	designerId: 		{type: ObjectId, required: true, unique: true},
	name: 				{type: String, required: true},
	description: 		{type: String, required: true},
	dateAdded: 			{type: Date, required: true}
});

designSchema.plugin(crate, {
	storage: new S3({
		key: 	config.key,
		secret: config.secret,
		bucket: config.bucket,
		acl: 	config.acl,
		region: config.region,
	}),
	fields: {
		mainImage: {
			processor: new ImageMagick({
				// tmpDir: '/tmp', // Where transformed files are placed before storage, defaults to os.tmpdir()
				// formats: ['JPEG', 'GIF', 'PNG'], // Supported formats, defaults to ['JPEG', 'GIF', 'PNG', 'TIFF']
				transforms: {
					original: {
						// keep the original file
					},
					small: {
						resize: '200x200',
						format: '.jpg'
					},
					medium: {
						resize: '300x300',
						format: '.jpg'
					},
					large: {
						resize: '500x500',
						format: '.jpg'
					},
					extraLarge: {
						resize: '1000x1000',
						format: '.jpg'
					}
				}
			})
		},
		additionalImages: {
			array: true,
			processor: new ImageMagick({
				// tmpDir: '/tmp', // Where transformed files are placed before storage, defaults to os.tmpdir()
				// formats: ['JPEG', 'GIF', 'PNG'], // Supported formats, defaults to ['JPEG', 'GIF', 'PNG', 'TIFF']
				transforms: {
					original: {
						// keep the original file
					},
					small: {
						resize: '200x200',
						format: '.jpg'
					},
					medium: {
						resize: '300x300',
						format: '.jpg'
					},
					large: {
						resize: '500x500',
						format: '.jpg'
					},
					extraLarge: {
						resize: '1000x1000',
						format: '.jpg'
					}
				}

			})
		},
		additionalFiles: {
			array: true
		}
	}
});


var userSchema = new Schema({
	username: 		{type: String, required: true, unique: true},
	email: 			{type: String, required: true, unique: true},
	firstName: 		{type: String, required: true},
	surname: 		{type: String, required: true},
	phoneNumber: 	{type: String}, //optional --NB. must make sure phone/address kept private, admin use only
	address: 		{type: String}, //optional
	bio: 			{type: String}, //optional
	links: 			[String], 		//optional
	dateJoined: 	{type: Date, required: true},
	isAdmin: 		{type: Boolean, required: true, default: false},
	// isDesigner	{type: Boolean, required: true, default: false}, //if taking user signups, e.g. to preorder
	designIds: 		[ObjectId]
});


userSchema.plugin(crate, {
	storage: new S3({
		key: 	config.key,
		secret: config.secret,
		bucket: config.bucket,
		acl: 	config.acl,
		region: config.region,
	}),
	fields: {
		profileImage: {
			processor: new ImageMagick({
				// tmpDir: '/tmp', // Where transformed files are placed before storage, defaults to os.tmpdir()
				// formats: ['JPEG', 'GIF', 'PNG'], // Supported formats, defaults to ['JPEG', 'GIF', 'PNG', 'TIFF']
				transforms: {
					original: {
						// keep the original file
					},
					small: {
						resize: '200x200',
						format: '.jpg'
					},
					medium: {
						resize: '300x300',
						format: '.jpg'
					},
					large: {
						resize: '500x500',
						format: '.jpg'
					}
				}
			})
		}
	}
});

var User 	= mongoose.model('user', userSchema, 'users');
var Design 	= mongoose.model('design', designSchema, 'designs');

module.exports= {
	User: User,
	Design: Design
};

{'fraction_non_alphanumeric': 0.16209010930418555, 'fraction_numerical': 0.01999466808850973, 'mean_word_length': 2.705185185185185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4771357', 'n_tokens_mistral': 3318, 'n_tokens_neox': 2581, 'n_words': 689}