Skip to content

BenchPress200/community-server-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

59 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Community Service


πŸ› οΈ Tech Stacks

JavaScript
Express


βš™οΈ Development Enviroment

MacOS Visual Studio Code




πŸš€ Getting Started

1. git clone

git clone https://github.com/BenchPress200/community-server-express.git

2. vscode둜 ν”„λ‘œμ νŠΈ open

  • ν•˜λ‚˜μ˜ 창에 community-server-express/frontend-server
  • λ‹€λ₯Έ ν•˜λ‚˜μ˜ 창에 community-server-express/backtend-server

3. package-lock.json 생성

  • 두 개의 vscode μ°½μ—μ„œ 각각 터미널을 μ—΄μ–΄μ„œ npm install λͺ…λ ΉμœΌλ‘œ package-lock.json 생성
npm install

4. globals.js μ—μ„œ ν”„λ‘ νŠΈμ—”λ“œ μ„œλ²„μ™€ λ°±μ—”λ“œ μ„œλ²„μ˜ IP μ£Όμ†Œμ™€ Port 번호 μ„ΈνŒ…

πŸ“‚ community-server-express/frontend-server/public/javascript/globals.js
πŸ“‚ community-server-express/backend-server/globals.js

βœ… 두 개의 globals.jsλ₯Ό λ˜‘κ°™μ΄ μž‘μ„±ν•΄μ•Ό 함


5. μ„œλ²„ μ‹€ν–‰

  • front, back 각각 ν„°λ―Έλ„μ—μ„œ npm startλ₯Ό 톡해 μ‹€ν–‰
npm start

6. Welcome Page

  • globals.jsμ—μ„œ FRONTEND_IP_PORT에 ν• λ‹Ήν–ˆλ˜ μ£Όμ†Œλ₯Ό λΈŒλΌμš°μ €μ—μ„œ μ£Όμ†Œμ°½μ— μž…λ ₯
export const FRONTEND_PORT = 8080;
export const FRONTEND_IP_PORT = `http://localhost:${FRONTEND_PORT}`;

⬆️ μœ„ 처럼 μž‘μ„±ν–ˆλ‹€λ©΄ http://localhost:8080 μ‚¬μš©




πŸ’₯ Features

  • νšŒμ›κ°€μž…

  • 둜그인

  • κ²Œμ‹œκΈ€ μž‘μ„±

  • κ²Œμ‹œκΈ€ 쑰회

  • κ²Œμ‹œκΈ€ μˆ˜μ •

  • κ²Œμ‹œκΈ€ μ‚­μ œ

  • λŒ“κΈ€ μž‘μ„±

  • λŒ“κΈ€ 쑰회

  • λŒ“κΈ€ μˆ˜μ •

  • λŒ“κΈ€ μ‚­μ œ

  • μœ μ € 정보 쑰회 및 μˆ˜μ •

  • μœ μ € 정보 μ‚­μ œ




🏯 Architecture

Project Architecture





Directory Structure

πŸ“‚ community-server-express
|
| - πŸ“‚ frontend-server
|   |
|   | - πŸ“‚ public # css, js, globals.js 
|   | - πŸ“‚ routes # μœ μ €, κ²Œμ‹œλ¬Ό λΌμš°ν„° λͺ¨λ“ˆ
|   | - πŸ“‚ view # html
|   | - app.js # ν”„λ‘ νŠΈμ—”λ“œ μ„œλ²„ 메인
|
| - πŸ“‚ backend-server
    |
    | - πŸ“‚ routes # μœ μ €, κ²Œμ‹œλ¬Ό λΌμš°ν„° λͺ¨λ“ˆ
    | - πŸ“‚ controllers # λΌμš°ν„°μ™€ λͺ¨λΈμ„ 쀑계, μœ μ €-κ²Œμ‹œλ¬Ό 컨트둀러
    | - πŸ“‚ models # μœ μ €-κ²Œμ‹œλ¬Ό λͺ¨λΈ, json 더미 데이터
    | - globals.js # IP μ£Όμ†Œ, port 번호
    | - app.js # λ°±μ—”λ“œ μ„œλ²„ 메인




etc.

  • DBμ‚¬μš© ❌
    • json 파일둜 데이터 관리

  • μ„Έμ…˜μœΌλ‘œ 인증, 인가 κ΅¬ν˜„

  • μ΄ˆκΈ°λ°μ΄ν„° μ„ΈνŒ…

    • 졜초 μ‹€ν–‰ μ‹œ, community-server-express/backend-server/models/repository/에 μžˆμ–΄μ•Όν•  μœ μ €, κ²Œμ‹œκΈ€, λŒ“κΈ€ jsonμ—†μŒ

function initData(req, res, next) {
    if (!fs.existsSync(path.join(__dirname, usersDataPath))) {
        const adminData = [
            {
                id: 0,
                email: '*******',
                password: '*****',
                nickname: 'admin',
                profileImage: "data:image/jpeg;base64,..."
            }
        ];
        
        
        fs.writeFileSync(path.join(__dirname, usersDataPath), JSON.stringify(adminData), 'utf8');
    } 


    if (!fs.existsSync(path.join(__dirname, postsDataPath))) {
        const adminPostData = [
            {
                id: 0,
                writer: 0,
                title: 'ν™˜μ˜ν•©λ‹ˆλ‹€!',
                time: '2024-05-01 11:00:00',
                image: '',
                content: 'λ°˜κ°’μŠ΅λ‹ˆλ‹€. ν™˜μ˜ν•©λ‹ˆλ‹€.',
                likes: 0,
                hits: 0,
                comments: 0
            }
        ];
        
        
        fs.writeFileSync(path.join(__dirname, postsDataPath), JSON.stringify(adminPostData), 'utf8');
    }


    if (!fs.existsSync(path.join(__dirname, commentsDataPath))) {
        const adminPostData = [
            {
                id: 0,
                postId: 0,
                writer: 0,
                time: '2024-05-01 11:00:00',
                text: 'λ°˜κ°‘μŠ΅λ‹ˆλ‹€.'
            }
        ];
        
        
        fs.writeFileSync(path.join(__dirname, commentsDataPath), JSON.stringify(adminPostData), 'utf8');
    } 
    
    next();
}

λ‹€μŒκ³Ό 같이, ν•΄λ‹Ή μ΄ˆκΈ°ν™” ν•¨μˆ˜λ₯Ό μœ μ € λΌμš°ν„°μ— λ―Έλ“€μ›¨μ–΄λ‘œ 등둝 users.json, posts.json, comments.json이 μ—†λ‹€λ©΄ μ΄ˆκΈ°λ°μ΄ν„°λ‘œ 생성해버림




🎯 Troubleshooting

  • 클릭 μš”μ†Œλ“€μ— λŒ€ν•œ 마우슀 포인터 λ³€κ²½
  • λ²„νŠΌλ“€ λͺ¨λ‘ ν˜Έλ²„ μΆ”κ°€
  • λΉ„λ°€λ²ˆν˜Έ μž…λ ₯κ³Ό λΉ„λ°€λ²ˆν˜Έ 확인 μž…λ ₯ 쀑 ν•˜λ‚˜λ§Œ μž…λ ₯ν–ˆμ„ λ•Œ μ μ ˆν•œ ν—¬νΌν…μŠ€νŠΈλ‘œ μˆ˜μ •
  • form μ œμΆœμ„ ν†΅ν•œ 이미지 μ €μž₯μ—μ„œ 파일 κ²½λ‘œκ°€ μ•„λ‹Œ data-url둜 μ €μž₯
  • 둜그인 λ²„νŠΌμ„ 톡해 둜그인 μ™„λ£Œ ν›„, ν•΄λ‹Ή λ²„νŠΌμ΄ 계속 ν΄λ¦­λ˜λŠ” 이슈
  • ν—¬νΌν…μŠ€νŠΈλ‘œ 인해 폼 μš”μ†Œ λ°€λ¦¬λŠ” 이슈
  • 각쒅 μœ νš¨μ„± 검사λ₯Ό 아웃포컀싱이 μ•„λ‹Œ μ¦‰μ‹œ μž…λ ₯을 νŒλ‹¨μœΌλ‘œ μœ νš¨μ„± 검사 진행
  • νšŒμ›κ°€μž… νŽ˜μ΄μ§€ ν—¬νΌν…μŠ€νŠΈ μ˜€νƒ€ 이슈

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published