<commit_before>const express = require('express');
const bodyParser = require('body-parser');
const multer = require('multer');

const CONSTANTS = require('../../../util/constants');
const authentication = require('../../../middlewares/authentication');

const authMiddleware = authentication.authMiddleware;

const IMAGE_TYPES = CONSTANTS.IMAGE_TYPES;

const upload = multer({
	storage: multer.diskStorage({
		destination: function (req, file, callBack) {
			return callBack(null, `public/portfolio/${req.user._id}`);
		},
		filename: function (req, file, callBack) {
			return callBack(null, `${file.fieldname}.${file.mimetype.split('/')[1]}`);
		}
	}),
	fileFilter: function (req, file, callBack) {
		if (IMAGE_TYPES.includes(file.mimetype.split('/')[1]))
			return callBack(null, true);
		return callBack(new Error(`Invalid File Type. File type must be ${IMAGE_TYPES.toString()}!`));
	}
});

const router = express.Router();

router.use(bodyParser.json());

/**
 * Student Upload Work
 */
router.post('/portfolio/new', authMiddleware, function (req, res, next) {});

/**
 * Error Handling Middleware
 */
router.use(function (err, req, res, next) {
	return res.status(500).json({
		error: err.toString()
	});
});

router.use(function (req, res, next) {
	return res.status(400).json({
		message: 'Invalid Or Missing Data'
	});
});<commit_msg>feat: View Portfolio Added View Portfolio Route. References #3 & #4<commit_after>const express = require('express');
const bodyParser = require('body-parser');
const multer = require('multer');

const CONSTANTS = require('../../../util/constants');
const Portfolio = require('../../../models/Portfolio');
const authentication = require('../../../middlewares/authentication');

const authMiddleware = authentication.authMiddleware;

const IMAGE_TYPES = CONSTANTS.IMAGE_TYPES;

const upload = multer({
	storage: multer.diskStorage({
		destination: function (req, file, callBack) {
			return callBack(null, `public/portfolio/${req.user._id}`);
		},
		filename: function (req, file, callBack) {
			return callBack(null, `${file.fieldname}.${file.mimetype.split('/')[1]}`);
		}
	}),
	fileFilter: function (req, file, callBack) {
		if (IMAGE_TYPES.includes(file.mimetype.split('/')[1]))
			return callBack(null, true);
		return callBack(new Error(`Invalid File Type. File type must be ${IMAGE_TYPES.toString()}!`));
	}
});

const router = express.Router();

router.use(bodyParser.json());

/**
 * Client View Portfolio
 */
router.get('/portfolio/page/:page', function (req, res, next) {
	let page = req.params.page;
	Portfolio.count(function (err, count) {
		if (err) {
			return next(err);
		}
		Portfolio.find({}, {}, {
			skip: 10 * (page - 1),
			limit: 10
		}, function (err, results) {
			if (err) {
				return next(err);
			}
			return res.json({
				message: 'Done'
			});
		});
	});
});

/**
 * Student Upload Work
 */
router.post('/portfolio/new', authMiddleware, function (req, res, next) {});

/**
 * Error Handling Middleware
 */
router.use(function (err, req, res, next) {
	return res.status(500).json({
		error: err.toString()
	});
});

router.use(function (req, res, next) {
	return res.status(400).json({
		message: 'Invalid Or Missing Data'
	});
});
{'fraction_non_alphanumeric': 0.18876755070202808, 'fraction_numerical': 0.007176287051482059, 'mean_word_length': 4.370184254606365, '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': '6486699', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1067, 'n_words': 244}