Add full project files
This commit is contained in:
35
scripts/disable-cdn-settings.js
Normal file
35
scripts/disable-cdn-settings.js
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# غیرفعال کردن CDN در دیتابیس (MongoDB)
|
||||
# اجرا: node /root/modstagram-back/scripts/disable-cdn-settings.js
|
||||
|
||||
const mongoose = require('mongoose')
|
||||
require('dotenv').config({ path: require('path').join(__dirname, '../.env') })
|
||||
|
||||
const MONGO_URI =
|
||||
process.env.MONGODB_URI ||
|
||||
process.env.MONGO_URI ||
|
||||
'mongodb://127.0.0.1:27017/modstagram'
|
||||
|
||||
const keys = {
|
||||
cdn_enabled: 'false',
|
||||
cdn_domain: 'cdn.modstagram.com',
|
||||
cdn_origin_url: 'https://api.modstagram.com',
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await mongoose.connect(MONGO_URI)
|
||||
const col = mongoose.connection.collection('settings')
|
||||
|
||||
for (const [key, value] of Object.entries(keys)) {
|
||||
await col.updateOne({ key }, { $set: { key, value: String(value) } }, { upsert: true })
|
||||
console.log(` ${key} = ${value}`)
|
||||
}
|
||||
|
||||
console.log('\nCDN disabled. image_base_url will be https://api.modstagram.com/storage')
|
||||
await mongoose.disconnect()
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user