Blog Website
This is a blog website built using Node.js and EJS. It allows users to create, read, update, and delete blog posts.
Before you can run this application, you'll need to have the following software installed on your computer:
- Node.js
- npm
- MongoDB Atlas account
You can download and install Node.js from the official website.
npm is included with Node.js, so once you have Node.js installed, you should have npm installed as well. You can check if npm is installed by running the following command in your terminal:
Copy code
npm -v
If you see a version number printed to the console, then npm is installed.
This application uses MongoDB Atlas to store blog post data. You can create a free account at the MongoDB website.
Once you have an account, follow these steps:
- Create a new project and a new cluster.
- Create a new database and a new collection for your blog posts.
Before you can run the application, you'll need to configure it with your MongoDB Atlas credentials.
- Create a new file named
.env
in the root directory of the project. - Open the
.env
file in a text editor and add the following lines:
makefileCopy code
MONGODB_URI=<your-mongodb-uri>
-
Replace
<your-mongodb-uri>
with your MongoDB Atlas connection string. You can find your connection string by following these steps:- Log in to your MongoDB Atlas account.
- Navigate to the cluster that you created earlier.
- Click the "Connect" button.
- Select "Connect your application".
- Select "Node.js" as the driver and "3.6 or later" as the version.
- Copy the connection string that is displayed on the page.
Your connection string should look something like this:
Copy code
mongodb+srv://<username>:<password>@<cluster-name>.mongodb.net/<database-name>?retryWrites=true&w=majority
-
Save the
.env
file.
To run the application, follow these steps:
-
Clone the repository to your local machine.
-
Open a terminal window and navigate to the project directory.
-
Run the following command to install the required dependencies:
Copy code
npm install
-
Run the following command to start the application:
sqlCopy code
npm start
-
Open your web browser and navigate to
http://localhost:4000
to view the application.
- Node.js
- Express
- EJS
- MongoDB Atlas