From 6593fbb8ecb7c85e0e3b6fc99f8b5075a9ca930a Mon Sep 17 00:00:00 2001 From: ramprasathmk Date: Tue, 7 Jan 2025 20:31:56 +0545 Subject: [PATCH 1/2] docs: update README.md Signed-off-by: ramprasathmk --- README.md | 58 ++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index bdd1ffc..cd1bfe9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Quote | Poem Posting Web Application +[![CI](https://github.com/ramprasathmk/poet-app/actions/workflows/poet-app_test.yml/badge.svg)](https://github.com/ramprasathmk/poet-app/actions/workflows/poet-app_test.yml) ## Description @@ -14,14 +15,17 @@ A simple web application that allows users to post, edit, and delete quotes. The - View all posted quotes -## Project Structure +## Prerequsites -- refer the Project Structure [here](./PROJECT_STRUCTURE.md). +- Node.js +- MongoDB Compass +- Visual Studio Code +- Web Browser (eg. chrome) -## Setup +## How To Run -1. **Clone the repository:** +1. **Clone the repo:** ```bash git clone https://github.com/ramprasathmk/poet-app.git cd poet-app @@ -32,34 +36,25 @@ A simple web application that allows users to post, edit, and delete quotes. The npm install ``` -3. **Start MongoDB:** Ensure MongoDB is running locally. If you're using a local installation, start MongoDB with: - ```bash - mongod - ``` - -4. **Start the application:** - ```bash - nodemon server.js - ``` - - otherwise, simply run the below **npm** command. - - ```bash - npm start +3. **Create .env file:** Create the file ./config.env with your Atlas URI and the server port: + ```text + MONGODB_URI=mongodb+srv://:@sandbox.jadwj.mongodb.net/db_name + PORT=3000 ``` -5. **Build the application:** build the application and run the production build. +4. **Check the MongoDB:** Ensure MongoDB is running locally. If you're using a local installation, start MongoDB with: ```bash - npm run build + mongod ``` +5. **Start the Server:** ```bash npm run dev ``` -6. **Pack the application:** packs application into `appname-version.tgz` file. +6. **Build the application:** build the application and run the production build. ```bash - npm pack + npm run build ``` 7. **Access the application:** Open your browser and navigate to http://localhost:3000 @@ -67,24 +62,13 @@ A simple web application that allows users to post, edit, and delete quotes. The ## Note -> - Create a `.env` file -> - Enter your port number, eg. PORT=3000 -> - Then, enter your mongodb url, eg. MONGODB_LOCAL_URL=mongodb://127.0.0.1:27017/your_database_name -> - Here `db_name` would be varied, so kindly use the same db_name for the whole project. +- Creating the `.env` file is mandatory. +- Provide the valid database name instead of `db_name`. eg. `quote_db` -## Sample Code: - -1. `.env` file: - - ```text - PORT=3000 - MONGODB_LOCAL_URL=mongodb://127.0.0.1:27017/quotes_db - ``` - +## Deployment -## 👇 Poet App is Deployed here - - [Poet App](https://poet-app.onrender.com) + - [Poet App](https://poet-app.onrender.com/) ## Usage From 32736201a0693913cfa2192a5cca5939dd012283 Mon Sep 17 00:00:00 2001 From: ramprasathmk Date: Tue, 7 Jan 2025 20:32:35 +0545 Subject: [PATCH 2/2] update file Signed-off-by: ramprasathmk --- controllers/poemsController.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/poemsController.js b/controllers/poemsController.js index c47622e..f91c92b 100644 --- a/controllers/poemsController.js +++ b/controllers/poemsController.js @@ -1,6 +1,8 @@ const Poem = require('../models/poem') -// Error handling middleware wrapper +/** + * Error handling middleware wrapper for `poemsController` + */ const asyncHandler = (fn) => { return (req, res, next) => { fn(req, res, next).catch(next)