Skip to content
Open
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
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CLOUDINARY_CLOUD_NAME=dig5tdmg2
CLOUDINARY_KEY=447215254574373
CLOUDINARY_SECRET=n-huQ68O9wGoNHAPPsqpTmYE7lI
MAPBOX_TOKEN=pk.eyJ1IjoiYXRoYXJ2MDIiLCJhIjoiY2t1aTZ4d3R4MDBpMjJ1cXpybjh0Z3ZwdSJ9.EPcOzFZhZz2d4VmWofErEg

DB_URL=mongodb+srv://ratemycamp:0KLp2MLGfq7402Dk@cluster0.cvlg0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
DB_SECRET=0KLp2MLGfq7402Dk
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# ratemycamp
$ npm install passport passport-local pass passport-local-mongoose
// Passport local passportLocalMongoose will add a Username,hash and salt field to store the username,the hashed password and the salt value.
# Rate My Camp
To install all dependancies : $ npm install
16 changes: 10 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ const mongoSanitize = require('express-mongo-sanitize');
const helmet = require("helmet");

// setting Mongo Atlas
const dbUrl = process.env.DB_URl || 'mongodb://localhost:27017/yelp-camp';
const MongoStore = require('connect-mongo');

const dbUrl = process.env.DB_URL;

// || 'mongodb://localhost:27017/yelp-camp';
mongoose.connect(dbUrl, {
useNewUrlParser: true,
// useCreateIndex: true,
Expand Down Expand Up @@ -59,14 +61,15 @@ app.use(
contentSecurityPolicy: false,
})
);
// setting up Atlas session

const secret = process.env.SECRET || 'thisshouldbeabettersecret!';

const secret = process.env.DB_SECRET || 'thisshouldbeabettersecret!'
const store = MongoStore.create({
mongoUrl: dbUrl,
secret,
touchAfter: 24 * 60 * 60,
// crypto: {
// secret: 'thisshouldbeabettersecret!',
// }
});

store.on("error", function(e) {
Expand Down Expand Up @@ -129,6 +132,7 @@ app.use((err, req, res, next) => {
res.status(statusCode).render('error', { err });
})

app.listen(3000, () => {
console.log('Listening on port 3000')
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Serving on port ${port}`)
})
Binary file added images/Kanchenjunga-Base-Camp-Trek 2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Kanchenjunga-Base-Camp-Trek.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bikecamp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/irshalgad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 34 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
{
"name": "ratemycamp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@mapbox/mapbox-sdk": "^0.13.2",
"cloudinary": "^1.27.0",
"connect-flash": "^0.1.1",
"connect-mongo": "^4.6.0",
"dotenv": "^10.0.0",
"ejs": "^3.1.6",
"ejs-mate": "^3.0.0",
"express": "^4.17.1",
"express-mongo-sanitize": "^2.1.0",
"express-session": "^1.17.2",
"helmet": "^4.6.0",
"joi": "^17.4.2",
"method-override": "^3.0.0",
"mongoose": "^6.0.0",
"multer": "^1.4.3",
"multer-storage-cloudinary": "^4.0.0",
"passport": "^0.5.0",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^6.1.0",
"sanitize-html": "^2.5.2"
}
}
"name": "ratemycamp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@mapbox/mapbox-sdk": "^0.13.2",
"cloudinary": "^1.27.0",
"connect-flash": "^0.1.1",
"connect-mongo": "^4.6.0",
"dotenv": "^10.0.0",
"ejs": "^3.1.6",
"ejs-mate": "^3.0.0",
"express": "^4.17.1",
"express-mongo-sanitize": "^2.1.0",
"express-session": "^1.17.2",
"helmet": "^4.6.0",
"joi": "^17.4.2",
"method-override": "^3.0.0",
"mongoose": "^6.0.0",
"multer": "^1.4.3",
"multer-storage-cloudinary": "^4.0.0",
"passport": "^0.5.0",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^6.1.0",
"sanitize-html": "^2.5.2"
}
}
4 changes: 0 additions & 4 deletions routes/campgrounds.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if (process.env.NODE_ENV !== "production") {
require('dotenv').config();
}

const express = require('express');
const router = express.Router();
const CatchAsync = require('../utils/CatchAsync');
Expand Down
2 changes: 1 addition & 1 deletion views/partials/navbar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<a class="nav-link" href="/campgrounds/new">New campgrounds</a>
</div>
<div class="navbar-nav ms-auto">
<% if(!currentUser){ %>
<% if(!currentUser) {%>
<a class="nav-link" href="/login">Login</a>
<a class="nav-link" href="/register">Register</a>
<% } else{ %>
Expand Down