Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test_branch #23

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

64 changes: 0 additions & 64 deletions PROJECT_STRUCTURE.md

This file was deleted.

1 change: 0 additions & 1 deletion Procfile

This file was deleted.

115 changes: 53 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,87 @@
# Quote | Poem Posting Web Application
# Poet App

[![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)
Poet App is a simple web application that allows users to post, edit, and delete quotes or poems. Built using Express.js and MongoDB, it provides a straightforward interface for managing literary entries.

## Description
[![CI Status](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)

A simple web application that allows you to post, edit, and delete quotes. The application is built using Express and MongoDB.

## Table of Contents

## Features

- Post new quotes
- Edit existing quotes
- Delete quotes
- View all posted quotes

[node]: https://nodejs.org/en/download
[mongo]: https://www.mongodb.com/try/download/compass
[code]: https://code.visualstudio.com/download
[chrome]: https://www.google.com/chrome/
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Project Structure](#project-structure)
- [Contributing](#contributing)

[//]: # (- [License](#license))

## Prerequsites
| Tools | Version |
|-----------|-----------|
| [Node.js][node] | 20.10.0 |
| [MongoDB Compass][mongo] | 7.x |
| [Visual Studio Code][code] | latest |
| [Web Browser][chrome] | latest |

## Features

## How To Run
- **Post Quotes/Poems**: Add new literary entries to the collection.
- **Edit Entries**: Modify existing quotes or poems.
- **Delete Entries**: Remove entries from the collection.
- **View All Entries**: Browse through all posted quotes and poems.

1. **Clone the repo:**
```bash
git clone https://github.com/ramprasathmk/poet-app.git
cd poet-app
```
## Prerequisites

2. **Install dependencies:**
```bash
npm install
```
Before you begin, ensure you have the following tools installed:

3. **Create .env file:** Create the `config.env` file in root directory.
```text
MONGODB_URI=mongodb+srv://<username>:<password>@sandbox.abcde.mongodb.net/db_name
PORT=3000
```
- **Node.js**: `>= 20.10.0`
- **MongoDB Compass**: `>= 7.x`
- **Visual Studio Code**: `latest`

4. **Check the MongoDB:** Ensure MongoDB is running locally.
```bash
mongod
```
## Installation

5. **Start the Server:**
```bash
npm run dev
```
1. **Clone the Repository**:

6. **Access the application:** Open your browser and navigate to http://localhost:3000
```bash
git clone https://github.com/ramprasathmk/poet-app.git
```

2. **Navigate to the Project Directory**:

## Deployment
```bash
cd poet-app
```

- [Poet App](https://poet-app.onrender.com/)
3. **Install Dependencies**:

```bash
npm install
```

## Usage

- Navigate to the home page to view all quotes.

- Use the form to "**Add**" a new quote.
1. **Start the Application**:

- Click "**Edit**" to modify an existing quote.
```bash
npm start
```

- Click "**Delete**" to remove a quote.
2. **Access the Application**:

Open your browser and navigate to `http://localhost:3000` to start using the Poet App.

## Technologies
## Project Structure

- Bootstrap CSS
The project follows a standard MVC (Model-View-Controller) architecture:

- Node.js
- `controllers/`: Contains the logic for handling requests and responses.
- `models/`: Defines the data schemas and interacts with the database.
- `routes/`: Manages the routing of HTTP requests.
- `views/`: Holds the EJS templates for rendering the frontend.
- `public/`: Includes static assets like CSS and JavaScript files.

- Express.js
## Contributing

- MongoDB
Contributions are welcome! If you have suggestions or improvements, please fork the repository and submit a pull request.

- Mongoose
[//]: # (## License)

- EJS (Embedded JavaScript templates)
[//]: # ()
[//]: # (This project is licensed under the MIT License. See the [LICENSE]&#40;LICENSE&#41; file for details.)

---

Feel free to modify this template to better suit your project’s specific needs. If you need further customization or have any questions, let me know!
Thank you for using Poet App! Feel free to explore, contribute, and share your favorite quotes and poems.
10 changes: 10 additions & 0 deletions controllers/usersController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const User = require('../models/user')

/**
* Error handling middleware wrapper for `usersController`
*/
const asyncHandler = (fn) => {
return (req, res, next) => {
fn(req, res, next).catch(next)
}
}
34 changes: 34 additions & 0 deletions models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const mongoose = require('mongoose')
const arrType = mongoose.Types.Array

/**
* User Schema {
* username: String, password: String, details: JSON | Object
* }
*/
const userSchema = new mongoose.Schema({
username: {
type: String,
unique: true,
},
password: {
type: String,
default: 'abc'
},
details: {
type: JSON | Object,
default: {}
},
poemId: {
type: arrType,
default: []
},
createdAt: {
type: Date,
default: Date.now
}
})

const User = mongoose.model('User', userSchema)

module.exports = User
Loading