Skip to content

Commit

Permalink
updated most of the issues and restructre the project directory (#58)
Browse files Browse the repository at this point in the history
Co-authored-by: yashksaini-coder <[email protected].>
  • Loading branch information
Nagesh-tri and yashksaini-coder authored Oct 18, 2024
1 parent 49afac8 commit 9946941
Show file tree
Hide file tree
Showing 11 changed files with 6,984 additions and 30 deletions.
28 changes: 14 additions & 14 deletions frontend/.gitignore → .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/backend/node_modules
/*/node_modules
/node_modules
/.pnp
.pnp.js
Expand All @@ -11,28 +11,28 @@
/coverage

# next.js
/.next/
/out/
/frontend/.next/
/*/out/

# production
/build
/*/build

# misc
.DS_Store
*.pem
/*/.DS_Store
/*/*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/*/npm-debug.log*
/*/yarn-debug.log*
/*/yarn-error.log*

# local env files
.env*.local
.env
/*/.env*.local
/backend/.env

# vercel
.vercel
/*/.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
/*/*.tsbuildinfo
/*/next-env.d.ts
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,31 @@ Bookstream is a dynamic, feature-rich bookstore application designed to provide
```
3. **Create Environment Variables**:

- Create a `.env` file by below command and add the following:
- Create a `.env` file (in backend workspace) by below command and add the following:
```bash
cd /backend
cp .env.example .env
```
- and update your MongoDB URI and JWT secret key in this file.
```bash
MONGODB_URI=your_mongo_db_uri
JWT_SECRET=your_jwt_secret
NEXT_PUBLIC_PAYMENT_API_KEY=your_payment_api_key
```

4. **Run the application in development**:
4. **Run the application**:
- back to parent directory
```bash
npm run dev
cd ../
npm run start
```
- This will start the application in production mode.
- you can also start backend and frontend by these commands:
- ```bash
npm run start:backend
npm run start:frontend
```

Access the app at `http://localhost:3000`.

### Important Note
Expand Down Expand Up @@ -147,6 +158,13 @@ In the book management section, fill out the form with book details (e.g., title
```bash
npm run dev
```
- This will start the application in production mode.
- you can also start backend and frontend by these commands:
- ```bash
npm run dev:backend
npm run dev:frontend
```
-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
2. **Edit and Update**:
Expand Down
2 changes: 1 addition & 1 deletion backend/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MONGO_URI=YOUR_MONGODB_URL
MONGO_URI=mongodb://localhost:27017/my-database
JWT_SECRET=SomeStringSecret
File renamed without changes.
10 changes: 10 additions & 0 deletions backend/config/mongoose-connection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI)
.then(() => {
console.log('MongoDB connected');
}).catch(err => {
console.log('Failed to connect to MongoDB', err);
});

module.exports=mongoose.connection;
3 changes: 2 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
"start": "node server.js",
"dev": "nodemon server.js"
},
"keywords": [],
"author": "",
Expand Down
12 changes: 2 additions & 10 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const mongoose = require('mongoose');
const db=require('./config/mongoose-connection');
const authRoutes = require('./routes/authRoutes');

const app = express();
const PORT = process.env.PORT || 8080;
const PORT = process.env.PORT || 5000;

app.use(cors());
app.use(express.json());

mongoose.connect(process.env.MONGO_URI, {useNewUrlParser: true,useUnifiedTopology: true})
.then(() => {
console.log('MongoDB connected');
}).catch(err => {
console.log('Failed to connect to MongoDB', err);
});

app.use('/api/auth',authRoutes);

// 404 Error Handler
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion frontend/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const geistMono = localFont({
});

export const metadata: Metadata = {
title: "Create Next App",
title: "BookStream",
description: "Generated by create next app",
};

Expand Down
Loading

0 comments on commit 9946941

Please sign in to comment.