import express from "express" import 'express-async-errors' import bodyParser from "body-parser"; import muteSwapEthForUsdc from "./script/zksync2/mute/swap.js"; import muteSwapUsdcForEth from "./script/zksync2/mute/swapUsdcForEth.js" import syncSwapEthForUsdc from "./script/zksync2/sync/swapEthForUsdc.js"; import syncSwapUsdcForEth from "./script/zksync2/sync/swapUsdcForEth.js" import tiktokfiMint from "./script/zksync2/tiktokfi/mint.js"; const app = express(); app.use(bodyParser.json()); const endMiddleware = (req, res, next) => { console.log(`request url: ${req.url}`); console.log(`request params: ${JSON.stringify(req.body.params)}`); console.log(`request address: ${JSON.stringify(req.body.wallet.address)}`); next(); }; app.use(endMiddleware) app.use("/zk-mute-swap-eth-usdc", muteSwapEthForUsdc) app.use("/zk-mute-swap-usdc-eth", muteSwapUsdcForEth) app.use("/zk-sync-swap-eth-usdc", syncSwapEthForUsdc) app.use("/zk-sync-swap-usdc-eth", syncSwapUsdcForEth) app.use("/zk-sync-tiktokfi-mint", tiktokfiMint) app.use((err, req, res, next) => { // 处理错误逻辑 console.error(err); // 输出错误信息到控制台 // 发送适当的错误响应给客户端 res.status(200).json({ code: 1, msg: err.message, data: null }); }); // 捕获未捕获的异常并处理 // process.on('uncaughtException', (err) => { // console.error('Uncaught Exception:', err); // // 进行适当的处理,例如记录错误、发送通知等 // // // 最后退出进程(可选) // }); // // process.on('unhandledRejection', (reason, promise) => { // console.error('Unhandled Rejection:', reason); // // 进行适当的处理,例如记录错误、发送通知等 // // // 最后退出进程(可选) // }); export default app;