|
|
@@ -3,7 +3,10 @@ const response = require('../utils/responseHandler')
|
|
|
const { notifWA } = require('../utils/notifFunction')
|
|
|
const sanksiModel = require('../model/sanksi.model')
|
|
|
const laporanModel = require('../model/laporan.model')
|
|
|
+const chunkModel = require('../model/chunk.model')
|
|
|
+const dokumenModel = require('../model/dokumen.model')
|
|
|
const backupModel = require('../model/backup.model')
|
|
|
+const pemantauanModel = require('../model/pemantauan.model')
|
|
|
const fs = require('fs')
|
|
|
const {
|
|
|
TEMPLATE_KEBERATAN,
|
|
|
@@ -386,7 +389,34 @@ exports.backup = handleError(async (req, res) => {
|
|
|
const mimetype = 'application/json'
|
|
|
const buffer = fs.readFileSync(path)
|
|
|
return { buffer, mimetype, size, originalname: 'user.json' }
|
|
|
- })()
|
|
|
+ })(),
|
|
|
+ (async () => {
|
|
|
+ const path = 'backup/' + new Date().getTime() + '-chunk.json'
|
|
|
+ const chunk = await chunkModel.find()
|
|
|
+ fs.writeFileSync(path, JSON.stringify(chunk))
|
|
|
+ const { size } = fs.statSync(path)
|
|
|
+ const mimetype = 'application/json'
|
|
|
+ const buffer = fs.readFileSync(path)
|
|
|
+ return { buffer, mimetype, size, originalname: 'chunk.json' }
|
|
|
+ })(),
|
|
|
+ (async () => {
|
|
|
+ const path = 'backup/' + new Date().getTime() + '-dokumen.json'
|
|
|
+ const dokumen = await dokumenModel.find()
|
|
|
+ fs.writeFileSync(path, JSON.stringify(dokumen))
|
|
|
+ const { size } = fs.statSync(path)
|
|
|
+ const mimetype = 'application/json'
|
|
|
+ const buffer = fs.readFileSync(path)
|
|
|
+ return { buffer, mimetype, size, originalname: 'dokumen.json' }
|
|
|
+ })(),
|
|
|
+ (async () => {
|
|
|
+ const path = 'backup/' + new Date().getTime() + '-pemantauan.json'
|
|
|
+ const pemantauan = await dokumenModel.find()
|
|
|
+ fs.writeFileSync(path, JSON.stringify(pemantauan))
|
|
|
+ const { size } = fs.statSync(path)
|
|
|
+ const mimetype = 'application/json'
|
|
|
+ const buffer = fs.readFileSync(path)
|
|
|
+ return { buffer, mimetype, size, originalname: 'pemantauan.json' }
|
|
|
+ })(),
|
|
|
])
|
|
|
const dokumen = await addManyDokumen(dataBakup)
|
|
|
const tes = await backupModel.create({
|