|
|
@@ -0,0 +1,39 @@
|
|
|
+import { io } from "socket.io-client"
|
|
|
+import axios from "axios"
|
|
|
+import { setTimeout } from "timers/promises"
|
|
|
+import chalk from "chalk"
|
|
|
+const axiosInstance = axios.create({
|
|
|
+ baseURL: "http://47.98.225.28/api",
|
|
|
+ headers: {
|
|
|
+ Authorization:
|
|
|
+ "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InpvdW1hQWRtaW4iLCJzdWIiOjEsInJvbGVzIjpbImFkbWluIl0sImlhdCI6MTcyNjU4MTk1OH0.dQiHFYaDDa1qp4OpEHaH5SCZ9dafJ8uO9fAAc8HZgAo"
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const {
|
|
|
+ data: { items: devices }
|
|
|
+} = await axiosInstance.post("/device", {
|
|
|
+ page: { page: 1, limit: 1000 },
|
|
|
+ search: {
|
|
|
+ where: { online: true, storing: true },
|
|
|
+ order: { name: "ASC" }
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+for (let device of devices) {
|
|
|
+ console.log(chalk.green(`${device.name} cancelStoreNumber`))
|
|
|
+ axiosInstance
|
|
|
+ .post(
|
|
|
+ `/device/${device.id}/sendMessage`,
|
|
|
+ {
|
|
|
+ action: "cancelStoreNumber",
|
|
|
+ data: {}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ timeout: 60000
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .catch(e => {
|
|
|
+ console.log(chalk.red(e.message))
|
|
|
+ })
|
|
|
+}
|