api call retry
This commit is contained in:
parent
c004f6c34f
commit
bb072cc91c
11 changed files with 126 additions and 23 deletions
|
|
@ -5,6 +5,7 @@ import { MiiTelWebhookSchema, processRequest } from "./logics/process";
|
|||
import { hubspotController } from "./logics/hubspot";
|
||||
import { createCustomError, responseError } from "./logics/error";
|
||||
import { CLOUD_STORAGE_LOG_FOLDER_NAME, CLOUD_STORAGE_MASTER_FOLDER_NAME, COMPANIES_FILE_NAME, OWNERS_FILE_NAME } from "../serverConfig";
|
||||
import { Delay } from "cerceis-lib";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
|
|
@ -78,13 +79,36 @@ router.post("/reExecute", async (req, res) => {
|
|||
|
||||
res.send(log);
|
||||
} catch(error) {
|
||||
console.log("===== Route Log =====")
|
||||
console.log(error);
|
||||
res.status(400).send("Failed");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 過去のログを全てGoogle Driveへアップロード
|
||||
router.post("/logUpload", async (req, res) => {
|
||||
try {
|
||||
const list = await storageController.getFileList();
|
||||
if(!list) throw createCustomError("GET_FILES_FAILED");
|
||||
for(const l of list){
|
||||
console.log(l);
|
||||
const fileName = l.split('/')[1]
|
||||
const log = await storageController.loadFromGCS('request_log', fileName);
|
||||
if(!log) throw createCustomError("GET_FILES_FAILED");
|
||||
// console.log(log);
|
||||
const parsedLog = MiiTelWebhookSchema.safeParse(JSON.parse(log));
|
||||
if(!parsedLog.success) throw createCustomError("ZOD_FAILED");
|
||||
console.log(parsedLog.data.video.title);
|
||||
|
||||
await Delay(500);
|
||||
}
|
||||
res.send('ok');
|
||||
} catch(error) {
|
||||
console.log(error);
|
||||
res.status(400).send("Failed");
|
||||
}
|
||||
});
|
||||
|
||||
// router.post("/deleteFile", async (req, res) => {
|
||||
// console.log(req.body);
|
||||
// const fileId = req.body.fileId;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue