Sindbad~EG File Manager
const fetch = require("node-fetch");
const getBack4MakeYear = async (req, res) => {
const response = await fetch(
"https://parseapi.back4app.com/classes/Car_Model_List?limit=200&keys=Year",
{
headers: {
"X-Parse-Application-Id": "hlhoNKjOvEhqzcVAJ1lxjicJLZNVv36GdbboZj3Z", // This is the fake app's application id
"X-Parse-Master-Key": "SNMJJF0CZZhTPhLDIqGhTlUNV9r60M2Z5spyWfXW", // This is the fake app's readonly master key
},
}
);
const data = await response.json(); // Here you have the data that you need
return res.json(data.results);
// console.log(JSON.stringify(data, null, 2));
};
const getBack4MakeByYear = async (req, res) => {
const where = encodeURIComponent(
JSON.stringify({
Year: req.body.year,
})
);
const response = await fetch(
// `https://parseapi.back4app.com/classes/Carmodels_Car_Model_List?excludeKeys=Category&where=${where}`,
`https://parseapi.back4app.com/classes/Carmodels_Car_Model_List?limit=500&keys=Make&where=${where}`,
{
headers: {
"X-Parse-Application-Id": "JxfQ24gRftYvOP5eSamTlGxRlPj1APU1ahqzhMz5", // This is your app's application id
"X-Parse-REST-API-Key": "QVd0BszmciBzA0n8dQRV8zJGs2QZi50CzoEuBIXQ", // This is your app's REST API key
},
}
);
const data = await response.json(); // Here you have the data that you need
const makes = data.results.map((item) => item.Make);
const uniqueMakes = [...new Set(makes)];
return res.json({ status: 200, data: uniqueMakes });
};
const getBack4ModelsByMake = async (req, res) => {
const where = encodeURIComponent(
JSON.stringify({
Make: req.body.make,
Year: req.body.year,
})
);
const response = await fetch(
`https://parseapi.back4app.com/classes/Carmodels_Car_Model_List?limit=1000&keys=Model&where=${where}`,
{
headers: {
"X-Parse-Application-Id": "JxfQ24gRftYvOP5eSamTlGxRlPj1APU1ahqzhMz5", // This is your app's application id
"X-Parse-REST-API-Key": "QVd0BszmciBzA0n8dQRV8zJGs2QZi50CzoEuBIXQ", // This is your app's REST API key
},
}
);
const data = await response.json(); // Here you have the data that you need
// return res.json(data.results);
const models = data.results.map((item) => item.Model);
const uniqueModels = [...new Set(models)];
return res.json({ status: 200, data: uniqueModels });
};
const getMakesByYear = async (req, res) => {
const { year } = req.body;
const url = `https://car-api2.p.rapidapi.com/api/makes?direction=asc&sort=id&year=${year}`;
const options = {
method: "GET",
headers: {
"X-RapidAPI-Key": "9a9177b404msh8540ff09175b264p151fe4jsn93b0b5d0dd5b",
"X-RapidAPI-Host": "car-api2.p.rapidapi.com",
},
};
try {
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const body = await response.json();
return res.json({ status: 200, message: "success", data: body });
} catch (error) {
console.error(error);
}
};
const getModelsByMake = async (req, res) => {
const { year, make } = req.body;
const url = `https://car-api2.p.rapidapi.com/api/models?make=${make}&sort=id&direction=asc&year=${year}&verbose=yes`;
const options = {
method: "GET",
headers: {
"X-RapidAPI-Key": "9a9177b404msh8540ff09175b264p151fe4jsn93b0b5d0dd5b",
"X-RapidAPI-Host": "car-api2.p.rapidapi.com",
},
};
try {
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const body = await response.json();
return res.json({ status: 200, message: "success", data: body });
} catch (error) {
console.error(error);
}
};
module.exports = { getBack4MakeByYear, getBack4ModelsByMake, getBack4MakeYear , getMakesByYear,
getModelsByMake};
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists