diff --git a/.env b/.env new file mode 100644 index 0000000..11b3a0f --- /dev/null +++ b/.env @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 5caa6ea..3f2aa1d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app.js b/app.js index 04b0db6..9146836 100644 --- a/app.js +++ b/app.js @@ -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, @@ -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) { @@ -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}`) }) \ No newline at end of file diff --git a/images/Kanchenjunga-Base-Camp-Trek 2.jpg b/images/Kanchenjunga-Base-Camp-Trek 2.jpg new file mode 100644 index 0000000..2f23318 Binary files /dev/null and b/images/Kanchenjunga-Base-Camp-Trek 2.jpg differ diff --git a/images/Kanchenjunga-Base-Camp-Trek.jpg b/images/Kanchenjunga-Base-Camp-Trek.jpg new file mode 100644 index 0000000..9614a78 Binary files /dev/null and b/images/Kanchenjunga-Base-Camp-Trek.jpg differ diff --git a/images/bikecamp.jpg b/images/bikecamp.jpg new file mode 100644 index 0000000..5536957 Binary files /dev/null and b/images/bikecamp.jpg differ diff --git a/images/irshalgad.jpg b/images/irshalgad.jpg new file mode 100644 index 0000000..dd32754 Binary files /dev/null and b/images/irshalgad.jpg differ diff --git a/package.json b/package.json index d77fbca..e6ac3ab 100644 --- a/package.json +++ b/package.json @@ -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" + } +} \ No newline at end of file diff --git a/routes/campgrounds.js b/routes/campgrounds.js index 9ddb979..8b5a905 100644 --- a/routes/campgrounds.js +++ b/routes/campgrounds.js @@ -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'); diff --git a/views/partials/navbar.ejs b/views/partials/navbar.ejs index c239d2f..cb09b18 100644 --- a/views/partials/navbar.ejs +++ b/views/partials/navbar.ejs @@ -11,7 +11,7 @@ New campgrounds