29 lines
769 B
JavaScript
29 lines
769 B
JavaScript
/**
|
|
* Manual/CI trigger for the same geo seed logic that also runs automatically
|
|
* on every backend boot (utils/ensureGeoData.js, wired in boot/mongo.js) —
|
|
* kept as a single shared implementation so the two paths never drift.
|
|
*
|
|
* Run from modstagram-back:
|
|
* node scripts/seedGeoData.js
|
|
*/
|
|
require('dotenv').config()
|
|
const mongoose = require('mongoose')
|
|
const { ensureGeoData } = require('../utils/ensureGeoData')
|
|
|
|
async function main() {
|
|
const uri = process.env.DATABASE_URL
|
|
if (!uri) {
|
|
console.error('DATABASE_URL is required (check .env)')
|
|
process.exit(1)
|
|
}
|
|
|
|
await mongoose.connect(uri, { authSource: 'admin' })
|
|
await ensureGeoData(true)
|
|
await mongoose.disconnect()
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|