송용우

Merge commit 'ac5aa59c' into feature/rest_api

SERVER_PORT=4000
\ No newline at end of file
SERVER_PORT=4000
MONGO_URL=mongodb://localhost:27017/jaksimsamil
\ No newline at end of file
......
const express = require("express");
const morgan = require("morgan");
const mongoose = require("mongoose");
const app = express();
require("dotenv").config();
const { SERVER_PORT, MONGO_URL } = process.env;
app.use(
morgan("[:date[iso]] :method :status :url :response-time(ms) :user-agent")
);
......@@ -10,6 +11,14 @@ app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use("/api", require("./api"));
app.listen(process.env.SERVER_PORT, () => {
mongoose
.connect(MONGO_URL, { useNewUrlParser: true, useFindAndModify: false })
.then(() => {
console.log("Connected to MongoDB");
})
.catch((e) => {
console.log(e);
});
app.listen(SERVER_PORT, () => {
console.log("Server is running on port", process.env.SERVER_PORT);
});
......
......@@ -4,9 +4,11 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"dotenv": "^8.2.0",
"eslint-config-prettier": "^6.11.0",
"express": "^4.17.1",
"fs": "^0.0.1-security",
"mongoose": "^5.9.17",
"morgan": "^1.10.0",
"path": "^0.12.7"
},
......
This diff is collapsed. Click to expand it.