Removed DB seeding.

This commit is contained in:
Tom Butcher 2025-12-13 22:34:46 +00:00
parent 55a1633eab
commit 8e0c991a58
3 changed files with 0 additions and 86 deletions

View File

@ -1,36 +0,0 @@
import mongoose from 'mongoose';
import bcrypt from 'bcrypt';
import { userModel } from '../schemas/management/user.schema.js';
import { dbConnect } from './mongo.js';
const ReseedAction = () => {
async function clear() {
dbConnect();
await userModel.deleteMany({});
console.log('DB cleared');
}
async function seedDB() {
await clear();
const salt = await bcrypt.genSalt(10);
const hashPassword = await bcrypt.hash('secret', salt);
const user = {
_id: mongoose.Types.ObjectId(1),
name: 'Admin',
email: 'admin@jsonapi.com',
password: hashPassword,
createdAt: new Date(),
profile_image: '../../images/admin.jpg',
};
const admin = new userModel(user);
await admin.save();
console.log('DB seeded');
}
seedDB();
};
export default ReseedAction;

View File

@ -1,42 +0,0 @@
import bcrypt from "bcrypt";
import mongoose from "mongoose";
import { userModel } from "../schemas/user.schema.js";
import { jobModel } from "../schemas/job.schema.js";
import { dbConnect } from "../mongo/index.js";
async function seedDB() {
dbConnect();
const salt = await bcrypt.genSalt(10);
const hashPassword = await bcrypt.hash("secret", salt);
const user = {
_id: new mongoose.Types.ObjectId(1),
name: "Admin",
email: "admin@jsonapi.com",
password: hashPassword,
createdAt: new Date(),
profile_image: "../../images/admin.jpg",
};
const admin = new userModel(user);
await admin.save();
const job = {
_id: new mongoose.Types.ObjectId(1),
status : {
type: "Queued"
},
createdAt: new Date(),
updatedAt: new Date(),
started_at: new Date(),
};
const newJob = new jobModel(job);
await newJob.save();
console.log("DB seeded");
}
seedDB().then(() => {
mongoose.connection.close();
});

View File

@ -40,8 +40,6 @@ import {
} from './routes/index.js';
import path from 'path';
import * as fs from 'fs';
import cron from 'node-cron';
import ReseedAction from './database/ReseedAction.js';
import log4js from 'log4js';
import { populateUserMiddleware } from './services/misc/auth.js';
import { natsServer } from './database/nats.js';
@ -142,11 +140,5 @@ app.use('/taxrates', taxRateRoutes);
app.use('/taxrecords', taxRecordRoutes);
app.use('/notes', noteRoutes);
if (process.env.SCHEDULE_HOUR) {
cron.schedule(`0 */${process.env.SCHEDULE_HOUR} * * *'`, () => {
ReseedAction();
});
}
// Start the application
initializeApp();