Skip to content

Commit

Permalink
refactor: move lib/connectDB and data/ to services dir
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalaciosg committed Aug 23, 2021
1 parent 3b875f5 commit 197c719
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nodepop/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ app.use(express.static(path.join(__dirname, "public")));
/**
* Conexión a la base de datos
*/
require("./lib/connectDB");
require("./services/mongoDB");
require("./models/Anuncio");
require("./controllers/AnuncioController");

Expand Down
4 changes: 2 additions & 2 deletions nodepop/install_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const fs = require("fs");
const fsPromises = fs.promises;

const mongoose = require("mongoose");
const conn = require("./lib/connectDB");
const conn = require("./services/mongoDB");
const Anuncio = require("./models/Anuncio");

const file = "./data/anuncios.json";
const file = "./services/data/anuncios.json";
const data = JSON.parse(fs.readFileSync(file,"utf-8"));

// conectar
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const mongoose = require("mongoose");
const conn = mongoose.connection;

mongoose.set('useFindAndModify', false);
mongoose.set("useFindAndModify", false);

// gestionar eventos de conexión
conn.on("error", err => {
Expand All @@ -18,6 +18,5 @@ conn.once("open", () => {

// conectar
mongoose.connect("mongodb://127.0.0.1/nodepop", { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true });

// exportar la conexión
module.exports = conn;

0 comments on commit 197c719

Please sign in to comment.