Skip to content

Commit

Permalink
Update Changes & Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nixrajput committed Jun 15, 2024
1 parent 10af3e8 commit 85f8cdb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 34 deletions.
28 changes: 28 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PORT=YOUR_PORT

MONGO_URI=YOUR_MONGODB_URL
DB_NAME=YOUR_DATABASE_NAME

NODE_ENV=dev
SERVER_MAINTENANCE='false'

JWT_SECRET=YOUR_SECRET
JWT_EXPIRES_IN=30d # CUSTOMIZE AS PER YOUR CHOICE

COOKIE_EXPIRES_IN=15 # CUSTOMIZE AS PER YOUR CHOICE

SMTP_FROM='Example <noreply@example.com>' # CUSTOMIZE AS PER YOUR CHOICE
SENDGRID_API_KEY=YOUR_SENDGRID_API_KEY

# Cloudinary
CLOUDINARY_CLOUD_NAME=YOUR_CLOUDINARY_CLOUD_NAME
CLOUDINARY_API_KEY=YOUR_CLOUDINARY_API_KEY
CLOUDINARY_API_SECRET=YOUR_CLOUDINARY_API_SECRET

# STRIPE CONFIG
STRIPE_API_KEY=YOUR_STRIPE_API_KEY
STRIPE_SECRET_KEY=YOUR_STRIPE_SECRET_KEY

# GitHub
GITHUB_TOKEN=YOUR_GITHUB_TOKEN
GITHUB_USERNAME=YOUR_GITHUB_USERNAME
39 changes: 11 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ This repository contains the source code for a E-commerce API built using Node.j

## Features

- User authentication and authorization.
- CRUD operations for users, jobs, and applications.
- JWT-based authentication for secure API access.
- RESTful API design.
- Written in TypeScript for enhanced maintainability and type safety.
- **User Authentication:** Register, login, and manage user accounts with JWT-based authentication.
- **Product Management:** CRUD operations for products.
- **Shopping Cart:** Add, update, and remove items in the shopping cart.
- **Order Management:** Place orders and view order history.
- **Stripe Payment Gateway:** Integrate Stripe for secure payment processing.
- **MongoDB Integration:** Store and manage data using MongoDB.

## Getting Started

Expand All @@ -48,6 +49,7 @@ You need to have the following software installed on your computer:

- [Node.js](https://nodejs.org/) (LTS version recommended)
- [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/) or [Yarn](https://yarnpkg.com/) package manager
- Stripe account and API keys

### Installation

Expand All @@ -62,7 +64,7 @@ You need to have the following software installed on your computer:
3. Navigate to the project directory:

```bash
cd portfolio-nextjs
cd ecommerce-api-nodejs
```

4. Install the project dependencies:
Expand Down Expand Up @@ -113,33 +115,14 @@ By default, the application will run on port `3000`. You can change the port by

## Deployment

This API can be deployed using various platforms such as Heroku, AWS, Google Cloud Platform, or your own server infrastructure. Here are some general steps to deploy the API:

1. **Prepare your environment**: Ensure that your deployment environment meets the requirements specified in the Prerequisites section.

2. **Build the application**: If necessary, build the TypeScript code into JavaScript. You can do this by running:

```bash
npm run build
#or
yarn build
```

3. **Configure environment variables**: Set up environment variables similar to how it's done in the local setup. Ensure that you provide appropriate values for your deployment environment.

4. **Deploy the application**: Deploy the built application to your chosen platform. Each platform may have its own deployment process. Refer to the documentation of your chosen platform for detailed instructions.

5. **Start the application**: Once deployed, start the application in your deployment environment. This might involve running a command similar to `npm start` or `yarn start`, depending on your setup.

6. **Monitor the deployment**: Monitor the deployed application for any issues. Make sure that it's running smoothly and handle any errors or performance issues as needed.
This API can be deployed using various platforms such as Vercel, Heroku, AWS, Google Cloud Platform, or your own server infrastructure. Set up environment variables similar to how it's done in the local setup. Ensure that you provide appropriate values for your deployment environment. Deploy the built application to your chosen platform. Each platform may have its own deployment process. Refer to the documentation of your chosen platform for detailed instructions. Monitor the deployed application for any issues. Make sure that it's running smoothly and handle any errors or performance issues as needed.

## Technologies Used

- Node.js
- Express.js
- JavaScript
- MongoDB (or any other database of your choice)
- Stripe
- MongoDB

## Contributing

Expand Down Expand Up @@ -175,6 +158,6 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
[gmail]: mailto:nkr.nikhil.nkr@gmail.com

[repo]: https://github.com/nixrajput/ecommerce-api-nodejs
[issues]: https://github.com/nixrajput/ecommerce-api-nodejs
[issues]: https://github.com/nixrajput/ecommerce-api-nodejs/issues
[pulls]: https://github.com/nixrajput/ecommerce-api-nodejs/pulls
[license]: https://github.com/nixrajput/ecommerce-api-nodejs/blob/master/LICENSE.md
10 changes: 4 additions & 6 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const app = runApp();
// Config
if (process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "prod") {
require("dotenv").config({
path: "./config.env",
path: "./.env.local",
});

console.log("[.env]: env values loaded");
}

// Cloudinary Setup
Expand Down Expand Up @@ -62,7 +64,6 @@ const connectToDatabase = function () {
console.log(`[server] running on port: ${port}`);
});


setTimeout(() => {
server.close();
connectToDatabase();
Expand Down Expand Up @@ -144,9 +145,7 @@ const connectToDatabase = function () {

app.listen(port, (err) => {
if (err) {
console.log(
`[server] could not start http server on port: ${port}`
);
console.log(`[server] could not start http server on port: ${port}`);
return;
}
console.log(`[server] running on port: ${port}`);
Expand All @@ -155,4 +154,3 @@ const connectToDatabase = function () {
connectToDatabase();
}
})();

0 comments on commit 85f8cdb

Please # to comment.