Update API Keys and fix frontend bugs
This commit is contained in:
@@ -132,6 +132,9 @@ exports.analyzeImage = async (req, res) => {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error analyzing image:', error.response ? JSON.stringify(error.response.data) : error.message);
|
||||
res.status(500).json({ error: error.message || 'Failed to analyze image' });
|
||||
res.status(500).json({
|
||||
error: error.message || 'Failed to analyze image',
|
||||
details: error.response ? error.response.data : null
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,8 +7,8 @@ dotenv.config({ path: path.join(__dirname, '../.env') });
|
||||
const Config = require('../models/Config');
|
||||
const { encrypt } = require('../utils/crypto');
|
||||
|
||||
const PERFECT_CORP_API_KEY = 'sk-tHtPU8rst9cifrM6RhkjCKy9EpNfXBdcoCbzP0QDRhIkHr_InBYPS6g_6XGSumbm';
|
||||
const PERFECT_CORP_SECRET_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCKexD/nyLrGq7jXCxYi/Tjwr297cZS5EUFQbCV9NO2XQU/sJitsT2WBHHS8AYAQrzM56hPgnwpt/B+EuSuLfVbM/ympBUvSrULUNlrJF5lW96JMd1KF8RWC9fICZJuCE2iGpGAd0l9pOCUmYM4JZ/n26HxZxSSramkoOYxmhFYhQIDAQAB';
|
||||
const PERFECT_CORP_API_KEY = 'sk-cKf0TV79X6Fp3CZwKfsnHv1Rq9GOK6nFCAXyDG9CvnIFKGYiTtSdOnjyadBaYc5y';
|
||||
const PERFECT_CORP_SECRET_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCAiLqa5kyq7FR9WmK++HCPNjGLsljLfvJQq+JZzCx7pfLlVD5KzRb17iglHQJkFkSHxfqxtYNwosA54oT9uD1kA96TJy+uOLRwxry7BMPTFQyDdIoloJCI/Bl+SEnSxjDoYpU8zA3S4GDkmLH3A7vHkxhMydgB8B1EOxJahQsF7QIDAQAB';
|
||||
|
||||
async function seedKeys() {
|
||||
try {
|
||||
@@ -38,3 +38,10 @@ async function seedKeys() {
|
||||
}
|
||||
|
||||
module.exports = seedKeys;
|
||||
|
||||
if (require.main === module) {
|
||||
seedKeys().then(() => {
|
||||
console.log('Seeding complete. Exiting.');
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
const axios = require('axios');
|
||||
const API_KEY = 'sk-cKf0TV79X6Fp3CZwKfsnHv1Rq9GOK6nFCAXyDG9CvnIFKGYiTtSdOnjyadBaYc5y';
|
||||
const baseUrl = 'https://yce-api-01.makeupar.com/s2s/v2.0';
|
||||
const initPayload = {
|
||||
files: [
|
||||
{ content_type: 'image/jpeg', file_name: 'test.jpg', file_size: 100000 }
|
||||
]
|
||||
};
|
||||
axios.post(`${baseUrl}/file`, initPayload, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${API_KEY}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(res => console.log('Init success:', JSON.stringify(res.data)))
|
||||
.catch(err => {
|
||||
console.error('Init failed:', err.response ? err.response.status : err.message);
|
||||
if(err.response) console.error(JSON.stringify(err.response.data));
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
const axios = require('axios');
|
||||
const API_KEY = 'sk-cKf0TV79X6Fp3CZwKfsnHv1Rq9GOK6nFCAXyDG9CvnIFKGYiTtSdOnjyadBaYc5y';
|
||||
const baseUrl = 'https://yce-api-01.makeupar.com/s2s/v2.0';
|
||||
|
||||
async function test() {
|
||||
try {
|
||||
const initPayload = {
|
||||
files: [
|
||||
{ content_type: 'image/jpeg', file_name: 'test.jpg', file_size: 100000 }
|
||||
]
|
||||
};
|
||||
|
||||
console.log('Init...');
|
||||
const res = await axios.post(`${baseUrl}/file`, initPayload, {
|
||||
headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const fileId = res.data.data.files[0].file_id;
|
||||
console.log('File ID:', fileId);
|
||||
|
||||
console.log('Creating task...');
|
||||
const taskPayload = {
|
||||
src_file_id: fileId,
|
||||
dst_actions: [
|
||||
"wrinkle", "pore", "texture", "acne", "moisture", "eye_bag",
|
||||
"firmness", "age_spot", "radiance", "redness", "oiliness"
|
||||
],
|
||||
miniserver_args: {
|
||||
enable_mask_overlay: false
|
||||
},
|
||||
format: "json"
|
||||
};
|
||||
|
||||
const taskRes = await axios.post(`${baseUrl}/task/skin-analysis`, taskPayload, {
|
||||
headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
console.log('Task success:', taskRes.data);
|
||||
} catch (err) {
|
||||
console.error('Failed:', err.response ? err.response.status : err.message);
|
||||
if(err.response) console.error(JSON.stringify(err.response.data, null, 2));
|
||||
}
|
||||
}
|
||||
test();
|
||||
Reference in New Issue
Block a user