Commit 42c6375b authored by Kim, Subin's avatar Kim, Subin
Browse files

express server 설정

parent ec88ca94
/node_modules
.env.dev
.env
\ No newline at end of file
This diff is collapsed.
......@@ -3,8 +3,10 @@
"version": "1.0.0",
"description": "KU 일정관리 앱",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon ./server/index.js"
},
"repository": {
"type": "git",
......@@ -16,5 +18,17 @@
"학사일정"
],
"author": "김수빈, 최가영",
"license": "ISC"
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"pg": "^8.7.1",
"pg-hstore": "^2.3.4",
"sequelize": "^6.6.5"
},
"devDependencies": {
"nodemon": "^2.0.13"
}
}
import express from 'express'
const app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
export default app
\ No newline at end of file
const config = {
env: process.env.NODE_ENV === 'production' ? 'production' : 'development',
port: process.env.PORT || 3001,
}
export default config
\ No newline at end of file
const config = {
host: 'localhost',
// username: process.env.PG_USER || 'butter',
// password: process.env.PG_PASSWORD || 'butter',
// database: process.env.PG_DATABASE || 'butterDB',
dialect: 'postgres',
pool: {
max: 10,
min: 0,
acquire: 30000,
idle: 10000,
}
}
export default config
\ No newline at end of file
import { Sequelize } from "sequelize"
import dbConfig from "../config/db.config.js"
const sequelize = new Sequelize(
String(dbConfig.database),
String(dbConfig.username),
dbConfig.password,
{
host: dbConfig.host,
dialect: dbConfig.dialect,
pool: {
max: dbConfig.pool?.max,
min: dbConfig.pool?.min,
acquire: dbConfig.pool?.acquire,
idle: dbConfig.pool?.idle,
},
}
);
export {
sequelize,
}
\ No newline at end of file
import dotenv from "dotenv"
import app from "./app.js"
import appConfig from "./config/app.config.js"
import sequelize from "sequelize"
// import { sequelize } from "./db/index.js"
dotenv.config({
path: `${process.env.NODE_ENV === "production" ? ".env" : ".env.development"
}`,
});
sequelize
// .sync({ force: false })
.then(() => {
app.listen(appConfig.port, () => {
console.log(`Server is running on port ${appConfig.port}`);
});
})
.catch((err) => {
console.log(err);
});
export default {}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment