Dès maintenant

rivez le logemerivez le logeme

Loyer : 800 € (Charges comprises)

Superficie: 190m²

Présentation

/**
 * Route uploading the photos of group in the page of groupWizard with the alias name 'photo'
 * @name 07-/groupPhotos/:groupUserId
 * @route {POST} /groupPhotos/:groupUserId
 * @memberof module:routes/uploadRoutes~uploadRouter
 * @routeparam {String} :groupUserId is the id of the user who creates the group
 */
router
	.route('/groupPhotos/:groupUserId')
	.post(upload.single('photo'), async (req, res) => {
		tools.log('Update fields', {
			id: `Photo - ${req.file.filename}`,
			preset: 'wizard',
		});

		const app_url =
			(process.env.LOCAL === 'true' ? 'https://' : 'http://') +
			req.headers.referer.split('/')[2];

		// Check if image compression is enabled
		if (process.env.COMPRESS_IMAGE === 'true') {
			const imageBuffer = fs.readFileSync(req.file.path); // Read the image as a buffer
			const image = sharp(imageBuffer);

			// Get metadata to check image dimensions
			const metadata = await image.metadata();

			// Define a threshold for resizing (e.g., 1000 pixels)
			const threshold = 1000;

			// Prepare the output file path for the WebP format
			const outputFilePath = path.format({
				dir: path.dirname(req.file.path),
				name: path.basename(req.file.path, path.extname(req.file.path)),
				ext: '.webp',
			});

			// Check if the image is larger than the threshold
			if (metadata.width > threshold || metadata.height > threshold) {
				// Resize the image if it's larger than the threshold
				await image
					.toFormat('webp', { quality: 90 }) // Convert to WebP and set quality
					.resize(threshold, threshold, { fit: 'inside' }) // Resize to fit within the threshold
					.toFile(outputFilePath, (err, info) => {
						if (err) {
							console.error('Error resizing image: ', err);
						}
					});
			} else {
				// If the image is smaller than the threshold, only convert to WebP without resizing
				await image
					.toFormat('webp', { quality: 90 }) // Convert to WebP and set quality
					.toFile(outputFilePath, (err, info) => {
						if (err) {
							console.error('Error converting image to WebP: ', err);
						}
					});
			}

			// Update the wizard's photo field with the new WebP file path
			updateWizard.updateFieldValue(
				req.params.groupUserId,
				{
					photos: path.basename(outputFilePath),
					$validation: 'image',
					$action: 'add',
				},
				res
			);
		} else {
			// If compression is disabled, use the original file
			updateWizard.updateFieldValue(
				req.params.groupUserId,
				{
					photos: req.file.filename,
					$validation: 'image',
					$action: 'add',
				},
				res
			);
		}
	});

Comment réserver sur Appartoo ?

Remplissez quelques informations et soumettez votre demande de réservation. Aucun paiement ne sera effectué tant que le propriétaire n'aura pas confirmé.

Le propriétaire examine votre demande et répond sous 24 heures. Si la demande est acceptée, vous pourrez finaliser votre réservation et organiser votre emménagement.

Une fois la réservation confirmée, préparez votre emménagement et récupérez les clés auprès du propriétaire. Vous avez 24 heures après votre arrivée pour signaler tout problème éventuel.

Chambres

Chambre disponible
Chambre disponible
Chambre disponible
Chambre disponible

Position

static google map
photo of Anwar
Anwar
Il y a 14 jours
Voir le numéro
14 vues
800 €
loader