-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from pknu-wap/server_main
Server main 병합
- Loading branch information
Showing
44 changed files
with
5,311 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
// IntelliSense를 사용하여 가능한 특성에 대해 알아보세요. | ||
// 기존 특성에 대한 설명을 보려면 가리킵니다. | ||
// 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요. | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "서버 실행 - 기본값", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"cwd": "${workspaceFolder}/server", | ||
"program": "${workspaceFolder}/server/bin/www.js" | ||
}, | ||
|
||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "서버 실행 - 재완 맥북", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"cwd": "${workspaceFolder}/server", | ||
"program": "${workspaceFolder}/server/bin/www.js", | ||
"runtimeExecutable": "${env:HOME}/.nvm/versions/node/v14.21.3/bin/node" | ||
} | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
### Node Patch ### | ||
# Serverless Webpack directories | ||
.webpack/ | ||
|
||
# Optional stylelint cache | ||
|
||
# SvelteKit build / generate output | ||
.svelte-kit | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
``` | ||
server | ||
├─ .gitignore | ||
├─ app.js | ||
├─ bin | ||
│ └─ www.js | ||
├─ migrations | ||
├─ package-lock.json | ||
├─ package.json | ||
├─ seeders | ||
└─ src | ||
├─ config | ||
├─ controller | ||
├─ routes | ||
├─ models | ||
└─ service | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
|
||
// 모듈 | ||
const express = require("express"); | ||
const app = express(); | ||
const bodyParser = require("body-parser"); | ||
const dotenv = require("dotenv"); | ||
dotenv.config(); | ||
const { swaggerUi, specs } = require("./swagger/swagger"); // swagger | ||
const path = require("path"); | ||
const { imgsDir } = require("./src/config/staticDirLoc"); // path to save uploaded files | ||
|
||
// 라우팅 | ||
const home = require("./src/routes/home"); | ||
|
||
// 미들웨어 | ||
// app.use(bodyParser.json()); | ||
app.use(express.json()); // 내장 body-parser | ||
app.use(express.urlencoded({ extended: true })); | ||
|
||
// set static folder | ||
app.use("/imgs", express.static(imgsDir)); // folder destination | ||
|
||
app.use("/", home); | ||
|
||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs)); | ||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"use strict"; | ||
|
||
const app = require("../app"); | ||
const models = require("../src/models/index.js"); | ||
const PORT = process.env.PORT || 3000; // 포트 | ||
const fs = require("fs"); | ||
const { imgsDir } = require("../src/config/staticDirLoc"); | ||
|
||
const { auto } = require("../src/config/sequelizeAuto"); | ||
|
||
const oracledb = require("oracledb"); | ||
|
||
app.listen(PORT, async () => { | ||
if (process.env.NODE_ENV == "development") { | ||
// 현재 개발 환경이라면 | ||
oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // 개발 머신에 따라 oracle client 경로 수동 설정 | ||
} | ||
|
||
try { | ||
await models.sequelize.sync({ force: false, alter: false }); | ||
} catch (err) { | ||
console.log("DB 연결 중 오류 발생: ", err); | ||
process.exit(); | ||
} | ||
|
||
// Find all users | ||
const users = await models.User.findAll(); | ||
console.log(users.every((user) => user instanceof models.User)); // true | ||
console.log("All users:", JSON.stringify(users, null, 2)); | ||
console.log( | ||
"All medicines:", | ||
JSON.stringify(await models.Medicine.findAll(), null, 2) | ||
); | ||
console.log( | ||
"All likes:", | ||
JSON.stringify(await models.Like.findAll(), null, 2) | ||
); | ||
console.log( | ||
"All comments:", | ||
JSON.stringify(await models.Comment.findAll(), null, 2) | ||
); | ||
console.log( | ||
"All favorite medicines:", | ||
JSON.stringify(await models.FavoriteMedicine.findAll(), null, 2) | ||
); | ||
|
||
// // model auto generation test | ||
// auto.run((err) => { | ||
// if (err) throw err; | ||
// console.log(auto.tables); // 생성된 모델 확인 | ||
// }); | ||
|
||
if (!fs.existsSync(imgsDir)) { // path doesn't exist | ||
try { | ||
fs.mkdirSync(imgsDir); // create directory | ||
console.log("Directory created successfully."); | ||
} catch (error) { | ||
console.error("Error creating directory:", error); | ||
} | ||
} | ||
|
||
console.log(`Server running on port ${PORT}`); | ||
}); |
Oops, something went wrong.