Welcome to the News Website project! This web application allows users to manage and interact with news articles. It includes user authentication, a search feature, and the ability to create, update, and delete articles. The project is designed to provide a clean and user-friendly interface, making it easy for users to navigate and manage news content.
- User Authentication: Secure login functionality to ensure that only authorized users can manage news articles.
- Search Bar: Quickly find articles by title using a responsive search feature.
- CRUD Operations:
- Create: Add new news articles effortlessly.
- Read: View a list of all news articles with relevant details.
- Update: Edit existing articles to keep content current and accurate.
- Delete: Remove articles that are no longer relevant with a simple click.
- Frontend: EJS (Embedded JavaScript Templates) for rendering dynamic HTML pages.
- Backend: Node.js and Express.js for server-side logic.
- Database: MongoDB for storing news articles and user data.
- Middleware:
cookie-sessionfor session management.body-parserfor parsing incoming request bodies.method-overridefor supporting PUT and DELETE requests.
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/LEWCHUNHONG/381project-60.git
-
Add mongodb uri: server.js
uri = '' -
Start server:
npm install npm start
-
Register:
Click Register Create account
-
Login:
Click Login
-
CURD:
Search, Edit, Delete News
-
RESTful API:
Create: curl -X POST -H "Content-Type: application/json" --data '{"title":"TEst news123","imageUrl":"","info":"THIS IS TEST!!!!"}' <IP:PORT>/api/news/ Read: curl -X GET "http://<ip:port>/api/title/<title>" Updata: curl -X PUT -H "Content-type: application/json" -d '{"imageUrl": "", "info": "Updated info"}' '<IP:PORT>/api/title/title/<title>' Delete: curl -X DELETE "<ip:port>/api/title/<title>"
Docker:
docker login
docker build -t 381-project-60 .
docker run -p <port>:<port> -d 381-project-60
docker stop <container-id>
docker rm <container-id>
docker image rm <image-id>