first commit

This commit is contained in:
Frank John Begornia
2025-12-23 01:51:15 +08:00
commit c926590e1d
4137 changed files with 613038 additions and 0 deletions

61
routes/jersey.js Normal file
View File

@@ -0,0 +1,61 @@
const express = require('express');
const router = express.Router();
const { checkScreenshotsExist, generateScreenshots, buildResponsePayload } = require('../utils/screenshot');
const { viewerUrls } = require('../config/config');
/**
* Jersey screenshot handler (4 views: front, back, right, left)
* Route: GET /jersey/:designId
*/
router.get('/:designId', async (req, res) => {
try {
const designId = req.params.designId;
console.log('Jersey screenshot request for design:', designId);
const filenames = {
thumb_front: `${designId}-front-thumbnail.png`,
thumb_back: `${designId}-back-thumbnail.png`,
thumb_right: `${designId}-right-thumbnail.png`,
thumb_left: `${designId}-left-thumbnail.png`
};
// Check if screenshots already exist
if (checkScreenshotsExist(Object.values(filenames))) {
console.log('Screenshots already exist, returning cached versions');
return res.status(200).jsonp(buildResponsePayload(filenames));
}
// Generate new screenshots
const url = `${viewerUrls.crewsportswear}${designId}/`;
const clipConfigs = [
{
filename: filenames.thumb_front,
clip: { x: 21.64, y: 48.11, width: 666, height: 520 }
},
{
filename: filenames.thumb_back,
clip: { x: 781.619, y: 48.11, width: 470, height: 520 }
},
{
filename: filenames.thumb_right,
clip: { x: 119.64, y: 584.407, width: 470, height: 520 }
},
{
filename: filenames.thumb_left,
clip: { x: 781.619, y: 584.407, width: 470, height: 520 }
}
];
await generateScreenshots(url, clipConfigs, { waitTime: 6000 });
res.status(200).jsonp(buildResponsePayload(filenames));
} catch (error) {
console.error('Jersey screenshot error:', error);
res.status(500).json({
error: 'Failed to generate screenshots',
message: error.message
});
}
});
module.exports = router;

86
routes/mask.js Normal file
View File

@@ -0,0 +1,86 @@
const express = require('express');
const router = express.Router();
const { checkScreenshotsExist, generateScreenshots, buildResponsePayload } = require('../utils/screenshot');
const { viewerUrls } = require('../config/config');
/**
* All-Over Print Mask screenshot handler (single front view)
* Route: GET /mask/:designId
*/
router.get('/:designId', async (req, res) => {
try {
const designId = req.params.designId;
console.log('All-Over Print Mask screenshot request for design:', designId);
const filenames = {
thumb_front: `${designId}-front-thumbnail.png`
};
// Check if screenshot already exists
if (checkScreenshotsExist(Object.values(filenames))) {
console.log('Screenshot already exists, returning cached version');
return res.status(200).jsonp(buildResponsePayload(filenames));
}
// Generate new screenshot
const url = `${viewerUrls.crewsportswear}${designId}/`;
const clipConfigs = [
{
filename: filenames.thumb_front,
clip: { x: 0, y: 0, width: 635, height: 600 }
}
];
await generateScreenshots(url, clipConfigs);
res.status(200).jsonp(buildResponsePayload(filenames));
} catch (error) {
console.error('All-Over Print Mask screenshot error:', error);
res.status(500).json({
error: 'Failed to generate screenshot',
message: error.message
});
}
});
/**
* Classic Mask screenshot handler (single front view with larger dimensions)
* Route: GET /mask/classic/:designId
*/
router.get('/classic/:designId', async (req, res) => {
try {
const designId = req.params.designId;
console.log('Classic Mask screenshot request for design:', designId);
const filenames = {
thumb_front: `${designId}-front-thumbnail.png`
};
// Check if screenshot already exists
if (checkScreenshotsExist(Object.values(filenames))) {
console.log('Screenshot already exists, returning cached version');
return res.status(200).jsonp(buildResponsePayload(filenames));
}
// Generate new screenshot
const url = `${viewerUrls.crewsportswear}${designId}/`;
const clipConfigs = [
{
filename: filenames.thumb_front,
clip: { x: 0, y: 0, width: 710, height: 600 }
}
];
await generateScreenshots(url, clipConfigs);
res.status(200).jsonp(buildResponsePayload(filenames));
} catch (error) {
console.error('Classic Mask screenshot error:', error);
res.status(500).json({
error: 'Failed to generate screenshot',
message: error.message
});
}
});
module.exports = router;

162
routes/merchbay.js Normal file
View File

@@ -0,0 +1,162 @@
const express = require('express');
const router = express.Router();
const { checkScreenshotsExist, generateScreenshots, buildResponsePayload } = require('../utils/screenshot');
const { viewerUrls } = require('../config/config');
/**
* Merchbay T-Shirt screenshot handler (4 views: front, back, right, left)
* Route: GET /merchbay/tshirt/:designId
*/
router.get('/tshirt/:designId', async (req, res) => {
try {
const designId = req.params.designId;
console.log('Merchbay T-Shirt screenshot request for design:', designId);
const filenames = {
thumb_front: `${designId}-front-thumbnail.png`,
thumb_back: `${designId}-back-thumbnail.png`,
thumb_right: `${designId}-right-thumbnail.png`,
thumb_left: `${designId}-left-thumbnail.png`
};
// Check if screenshots already exist
if (checkScreenshotsExist(Object.values(filenames))) {
console.log('Screenshots already exist, returning cached versions');
return res.status(200).jsonp(buildResponsePayload(filenames));
}
// Generate new screenshots
const url = `${viewerUrls.merchbay}${designId}/`;
const clipConfigs = [
{
filename: filenames.thumb_front,
clip: { x: 120, y: 37.11, width: 470, height: 520 }
},
{
filename: filenames.thumb_back,
clip: { x: 776.967, y: 37.11, width: 470, height: 520 }
},
{
filename: filenames.thumb_right,
clip: { x: 120, y: 557, width: 470, height: 520 }
},
{
filename: filenames.thumb_left,
clip: { x: 776.967, y: 557, width: 470, height: 520 }
}
];
await generateScreenshots(url, clipConfigs);
res.status(200).jsonp(buildResponsePayload(filenames));
} catch (error) {
console.error('Merchbay T-Shirt screenshot error:', error);
res.status(500).json({
error: 'Failed to generate screenshots',
message: error.message
});
}
});
/**
* Merchbay All-Over Print screenshot handler (2 views: front, back)
* Route: GET /merchbay/allover/:designId
*/
router.get('/allover/:designId', async (req, res) => {
try {
const designId = req.params.designId;
console.log('Merchbay All-Over Print screenshot request for design:', designId);
const filenames = {
thumb_front: `${designId}-front-thumbnail.png`,
thumb_back: `${designId}-back-thumbnail.png`
};
// Check if screenshots already exist
if (checkScreenshotsExist(Object.values(filenames))) {
console.log('Screenshots already exist, returning cached versions');
return res.status(200).jsonp(buildResponsePayload(filenames));
}
// Generate new screenshots
const url = `${viewerUrls.merchbay}${designId}/`;
const clipConfigs = [
{
filename: filenames.thumb_front,
clip: { x: 56.5, y: 40, width: 470, height: 520 }
},
{
filename: filenames.thumb_back,
clip: { x: 716.78, y: 40, width: 470, height: 520 }
}
];
await generateScreenshots(url, clipConfigs);
res.status(200).jsonp(buildResponsePayload(filenames));
} catch (error) {
console.error('Merchbay All-Over Print screenshot error:', error);
res.status(500).json({
error: 'Failed to generate screenshots',
message: error.message
});
}
});
/**
* Merchbay Legacy T-Shirt screenshot handler (4 views: front, back, right, left)
* Uses legacy viewer URL format
* Route: GET /merchbay/legacy/:designId
*/
router.get('/legacy/:designId', async (req, res) => {
try {
const designId = req.params.designId;
console.log('Merchbay Legacy screenshot request for design:', designId);
const filenames = {
thumb_front: `${designId}-front-thumbnail.png`,
thumb_back: `${designId}-back-thumbnail.png`,
thumb_right: `${designId}-right-thumbnail.png`,
thumb_left: `${designId}-left-thumbnail.png`
};
// Check if screenshots already exist
if (checkScreenshotsExist(Object.values(filenames))) {
console.log('Screenshots already exist, returning cached versions');
return res.status(200).jsonp(buildResponsePayload(filenames));
}
// Generate new screenshots using legacy URL format
const url = `${viewerUrls.merchbayLegacy}${designId}`;
const clipConfigs = [
{
filename: filenames.thumb_front,
clip: { x: 120, y: 37.11, width: 470, height: 520 }
},
{
filename: filenames.thumb_back,
clip: { x: 776.967, y: 37.11, width: 470, height: 520 }
},
{
filename: filenames.thumb_right,
clip: { x: 120, y: 557, width: 470, height: 520 }
},
{
filename: filenames.thumb_left,
clip: { x: 776.967, y: 557, width: 470, height: 520 }
}
];
await generateScreenshots(url, clipConfigs);
res.status(200).jsonp(buildResponsePayload(filenames));
} catch (error) {
console.error('Merchbay Legacy screenshot error:', error);
res.status(500).json({
error: 'Failed to generate screenshots',
message: error.message
});
}
});
module.exports = router;

106
routes/tshirt.js Normal file
View File

@@ -0,0 +1,106 @@
const express = require('express');
const router = express.Router();
const { checkScreenshotsExist, generateScreenshots, buildResponsePayload } = require('../utils/screenshot');
const { viewerUrls } = require('../config/config');
/**
* T-Shirt screenshot handler (4 views: front, back, right, left)
* Route: GET /tshirt/:designId
*/
router.get('/:designId', async (req, res) => {
try {
const designId = req.params.designId;
console.log('T-Shirt screenshot request for design:', designId);
const filenames = {
thumb_front: `${designId}-front-thumbnail.png`,
thumb_back: `${designId}-back-thumbnail.png`,
thumb_right: `${designId}-right-thumbnail.png`,
thumb_left: `${designId}-left-thumbnail.png`
};
// Check if screenshots already exist
if (checkScreenshotsExist(Object.values(filenames))) {
console.log('Screenshots already exist, returning cached versions');
return res.status(200).jsonp(buildResponsePayload(filenames));
}
// Generate new screenshots
const url = `${viewerUrls.crewsportswear}${designId}/`;
const clipConfigs = [
{
filename: filenames.thumb_front,
clip: { x: 120, y: 37.11, width: 470, height: 520 }
},
{
filename: filenames.thumb_back,
clip: { x: 776.967, y: 37.11, width: 470, height: 520 }
},
{
filename: filenames.thumb_right,
clip: { x: 120, y: 557, width: 470, height: 520 }
},
{
filename: filenames.thumb_left,
clip: { x: 776.967, y: 557, width: 470, height: 520 }
}
];
await generateScreenshots(url, clipConfigs);
res.status(200).jsonp(buildResponsePayload(filenames));
} catch (error) {
console.error('T-Shirt screenshot error:', error);
res.status(500).json({
error: 'Failed to generate screenshots',
message: error.message
});
}
});
/**
* T-Shirt All-Over Print screenshot handler (2 views: front, back)
* Route: GET /tshirt/allover/:designId
*/
router.get('/allover/:designId', async (req, res) => {
try {
const designId = req.params.designId;
console.log('T-Shirt All-Over Print screenshot request for design:', designId);
const filenames = {
thumb_front: `${designId}-front-thumbnail.png`,
thumb_back: `${designId}-back-thumbnail.png`
};
// Check if screenshots already exist
if (checkScreenshotsExist(Object.values(filenames))) {
console.log('Screenshots already exist, returning cached versions');
return res.status(200).jsonp(buildResponsePayload(filenames));
}
// Generate new screenshots
const url = `${viewerUrls.crewsportswear}${designId}/`;
const clipConfigs = [
{
filename: filenames.thumb_front,
clip: { x: 56.5, y: 40, width: 470, height: 520 }
},
{
filename: filenames.thumb_back,
clip: { x: 716.78, y: 40, width: 470, height: 520 }
}
];
await generateScreenshots(url, clipConfigs);
res.status(200).jsonp(buildResponsePayload(filenames));
} catch (error) {
console.error('T-Shirt All-Over Print screenshot error:', error);
res.status(500).json({
error: 'Failed to generate screenshots',
message: error.message
});
}
});
module.exports = router;