This repository contains the backend codebase for the Community Project, handling business logic, database operations, and API endpoints. It is built with Node.js and MariaDB.
- π RESTful APIs for CRUD operations on posts and comments
- π User authentication and session management
- π€ Profile management with image uploads
- βοΈ Transaction handling for data consistency
- π Secure password hashing and data validation
Node.js β Server-side runtime
Express β Web framework
MariaDB β Database
bcrypt β Password hashing
Multer β File uploads
-
Clone the repository:
git clone https://github.com/100-hours-a-week/2-hayden-shin-community-be.git cd backend -
Install dependencies:
npm install
-
Create a
.envfile in the root directory:DB_HOST=localhost DB_USER=root DB_PASSWORD=yourpassword DB_DATABASE=community SESSION_SECRET=yoursecret -
Start the server:
npm start
βββ controller/
β βββ post.js
β βββ comment.js
β βββ auth.js
βββ model/
β βββ post.js
β βββ comment.js
β βββ auth.js
βββ router/
β βββ post.js
β βββ comment.js
β βββ auth.js
βββ db/
β βββ database.js
- POST /auth/signup β Register a new user
- POST /auth/login β Log in a user
- POST /auth/logout β Log out the current user
- GET /posts β Retrieve all posts
- GET /posts/:post_id β Retrieve a specific post
- POST /posts β Create a new post
- PATCH /posts/:post_id β Update a post
- DELETE /posts/:post_id β Delete a post
- GET /posts/:post_id/comments β Retrieve comments for a specific post
- POST /posts/:post_id/comments β Add a comment to a post
- PATCH /comments/:comment_id β Update a comment
- DELETE /comments/:comment_id β Delete a comment
- id, username, email, password, profileImage, createdAt
- id, title, content, image, userId, likeCount, viewCount, commentCount, createdAt, updatedAt
- id, postId, content, userId, createdAt, updatedAt
- id, postId, userId, createdAt
-
Fork the repository
-
Create a new branch
git checkout -b feature-name
-
Commit your changes
git commit -m "feat: add feature" -
Push your branch
git push origin feature-name
-
Open a pull request