Skip to content

Commit

Permalink
Merge pull request #18 from soohwanpak/react-박수환-sprint-6
Browse files Browse the repository at this point in the history
dotenv설정
  • Loading branch information
soohwanpak authored Nov 3, 2024
2 parents 2816479 + 4abe7d1 commit 621da39
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ lerna-debug.log*
node_modules
/react-psh-sprint5/node_modules/
/express-psh-sprint6/node_modules/
/express-psh-sprint6/env.js
/express-psh-sprint6/.env
/react-psh-sprint5/src/features/api/url.jsx
dist
dist-ssr
*.local

.env
# Editor directories and files
.vscode/*
!.vscode/extensions.json
Expand Down
7 changes: 5 additions & 2 deletions express-psh-sprint-6/data/seeds.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import mongoose, { mongo } from "mongoose";
import { Data } from "./mockData.js";
import { DATABASE_URL } from "../env.js";
import dotenv from 'dotenv';
import Product from "../models/Product.js";

mongoose.connect(DATABASE_URL);
dotenv.config();
const dbUrl = process.env.DATABASE_URL;

mongoose.connect(dbUrl);

await Product.deleteMany({});
await Product.insertMany(Data.list);
Expand Down
2 changes: 0 additions & 2 deletions express-psh-sprint-6/env.js

This file was deleted.

8 changes: 5 additions & 3 deletions express-psh-sprint-6/server.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import express from "express";
import cors from "cors";
import router from "./controllers/routes/routes.js";
import { DATABASE_URL } from "./env.js";
import dotenv from 'dotenv';
import mongoose from "mongoose";

const app = express();
app.use(cors());

app.use(express.json());

dotenv.config();
const dbUrl = process.env.DATABASE_URL;

mongoose
.connect(DATABASE_URL)
.connect(dbUrl)
.then(() => console.log("MongoDB connected"))
.catch((err) => console.log(err));

Expand Down
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"dependencies": {
"concurrently": "^9.0.1"
"concurrently": "^9.0.1",
"dotenv": "^16.4.5"
},
"scripts": {
"start": "concurrently \"cd express-psh-sprint-6 && npm run dev\" \"cd react-psh-sprint-5 && npm run dev\""
}
}
}

0 comments on commit 621da39

Please sign in to comment.