diff --git a/app.js b/app.js index be50642..f104a2b 100644 --- a/app.js +++ b/app.js @@ -10,7 +10,7 @@ var expressValidator = require('express-validator');//req.checkbody() const mongoConfig = require('./configs/mongo-config') var indexRouter = require('./routes/index'); var usersRouter = require('./routes/users'); - +require('dotenv').config({path:'variables.env'}); mongoose.connect(mongoConfig, { useNewUrlParser: true, useCreateIndex: true, },function(error){ if(error) throw error console.log(`connect mongodb success`); @@ -62,5 +62,4 @@ app.use(function(err, req, res, next) { // console.log(err); res.status(err.status || 500).json(err); }); - module.exports = app; diff --git a/bin/www b/bin/www index 6100eaf..b1e0992 100755 --- a/bin/www +++ b/bin/www @@ -13,7 +13,7 @@ var PORT = process.argv[2]&&process.argv[2].slice(-4) * Get port from environment and store in Express. */ -var port = normalizePort(process.env.PORT || PORT || '3000'); +var port = normalizePort(process.env.PORT || PORT || '4000'); app.set('port', port); /** diff --git a/configs/mongo-config.js b/configs/mongo-config.js index 3690269..2d70368 100644 --- a/configs/mongo-config.js +++ b/configs/mongo-config.js @@ -1 +1,5 @@ -// export mongodb url +//const direccion="mongodb://localhost:27017/DataEComerceNode"; +//const direccion="mongodb+srv://admin:@cluster0.ikple.mongodb.net/test" +const direccion ="mongodb+srv://unsaac:unsaac123@primero.6gh6z.mongodb.net/EcommerceUnsaacBD?retryWrites=true&w=majority" +//const direccion="mongodb+srv://unsaac:unsaac123@primero.6gh6z.mongodb.net/EcommerceUnsaac?retryWrites=true&w=majority" +module.exports = direccion; diff --git a/package-lock.json b/package-lock.json index 51fcd06..169119a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "myapp", - "version": "0.0.0", + "name": "ecommerce-nodejs", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -846,6 +846,11 @@ "is-obj": "^1.0.0" } }, + "dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", diff --git a/package.json b/package.json index ea8cea2..8c81ed4 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "cookie-parser": "^1.4.4", "cors": "^2.8.5", "debug": "^2.6.9", + "dotenv": "^8.2.0", "express": "^4.16.4", "express-handlebars": "^3.0.2", "express-messages": "^1.0.1", diff --git a/routes/index.js b/routes/index.js index 005508b..89c34e9 100644 --- a/routes/index.js +++ b/routes/index.js @@ -164,9 +164,9 @@ router.get('/filter', function (req, res, next) { //GET /checkout router.get('/checkout/:cartId', ensureAuthenticated, function (req, res, next) { const cartId = req.params.cartId - const frontURL = 'https://zack-ecommerce-reactjs.herokuapp.com' - // const frontURL = 'http://localhost:3000' - + //const frontURL = 'https://zack-ecommerce-reactjs.herokuapp.com' + //const frontURL = 'http://localhost:3000' + const frontURL="https://ecommerce-react-unsaac1.herokuapp.com/" ; Cart.getCartById(cartId, function (err, c) { if (err) return next(err) if (!c) { diff --git a/seed/index.js b/seed/index.js index e2d9001..9f898d5 100644 --- a/seed/index.js +++ b/seed/index.js @@ -11,25 +11,25 @@ mongoose.connect(mongoConfig, { useNewUrlParser: true, useCreateIndex: true, }); var categories = [ new Category({ - categoryName: 'Basics' + categoryName: 'Basicos' }), new Category({ - categoryName: 'Blazer' + categoryName: 'Chaqueta' }), new Category({ - categoryName: 'Knitwear' + categoryName: 'Prendas de punto' }), new Category({ categoryName: 'Jeans' }), new Category({ - categoryName: 'Jackets' + categoryName: 'Campera' }), new Category({ - categoryName: 'Girl' + categoryName: 'Niña' }), new Category({ - categoryName: 'Boy' + categoryName: 'Niño' }) ] @@ -44,17 +44,17 @@ for (let i = 0; i < categories.length; i++) { var departments = [ new Department({ - departmentName: 'Women', - categories: 'Basics,Blazer' + departmentName: 'Mujeres', + categories: 'Basicos,Chaqueta' }), new Department({ - departmentName: 'Men', - categories: 'Knitwear,Jeans,Jackets' + departmentName: 'Varones', + categories: 'Prendas de punto,Jeans,Campera' }), new Department({ - departmentName: 'Kids', - categories: 'Girl,Boy' + departmentName: 'Niños', + categories: 'Niña,Niño' }) ] @@ -77,8 +77,8 @@ var products = color: 'Gray', size: 'XS,S,M', quantity: 10, - department: 'Women', - category: 'Basics', + department: 'Mujeres', + category: 'Basicos', date: 1581397200000 }), new Product({ @@ -90,8 +90,8 @@ var products = color: 'Black', size: 'XS,S,XL', quantity: 15, - department: 'Women', - category: 'Basics', + department: 'Mujeres', + category: 'Basicos', date: 1597885814264 }), new Product({ @@ -103,21 +103,21 @@ var products = color: 'White', size: 'XS', quantity: 90, - department: 'Women', - category: 'Basics', + department: 'Mujeres', + category: 'Basicos', date: 1581397200000 }), new Product({ _id: "5bedf55bc14d7822b39d9d4b", imagePath: 'https://static.zara.net/photos///2018/I/0/1/p/8197/757/093/4/w/1920/8197757093_2_2_1.jpg?ts=1538393944729', - title: 'Belted Plaid Blazer', - description: 'Flowy blazer with lapel collar and long sleeves. Self belt. Chest patch pockets and welt pockets at hip. Front double-breasted button closure.', + title: 'Belted Plaid Chaqueta', + description: 'Flowy Chaqueta with lapel collar and long sleeves. Self belt. Chest patch pockets and welt pockets at hip. Front double-breasted button closure.', price: 79.99, color: 'Black', size: 'S,M,L', quantity: 4, - department: 'Women', - category: 'Blazer', + department: 'Mujeres', + category: 'Chaqueta', date: 1581397200000 }), new Product({ @@ -129,8 +129,8 @@ var products = color: 'Orange', size: 'M,L', quantity: 5, - department: 'Men', - category: 'Knitwear', + department: 'Varones', + category: 'Prendas de punto', date: 1597885814264 }), new Product({ @@ -142,7 +142,7 @@ var products = color: 'Dark Blue', size: 'M,L', quantity: 80, - department: 'Men', + department: 'Varones', category: 'Jeans', date: 1597885814264 }), @@ -155,7 +155,7 @@ var products = color: 'Light Blue', size: 'XS,S,M', quantity: 8, - department: 'Men', + department: 'Varones', category: 'Jeans', date: 1581397200000 }), @@ -168,8 +168,8 @@ var products = color: 'Brown', size: 'XS,M,XL', quantity: 12, - department: 'Men', - category: 'Jackets', + department: 'Varones', + category: 'Campera', date: 1581397200000 }), new Product({ @@ -181,8 +181,8 @@ var products = color: 'OYSTER WHITE', size: 'XS,M', quantity: 23, - department: 'Kids', - category: 'Girl', + department: 'Niños', + category: 'Niña', date: 1597962874736 }), new Product({ @@ -194,8 +194,8 @@ var products = color: 'BLACK ', size: 'XS', quantity: 23, - department: 'Kids', - category: 'Boy', + department: 'Niños', + category: 'Niño', date: 1597962874736 }), ]; diff --git a/seed/procfile b/seed/procfile new file mode 100644 index 0000000..9641b92 --- /dev/null +++ b/seed/procfile @@ -0,0 +1 @@ +web:npm start \ No newline at end of file diff --git a/seed/variables.env b/seed/variables.env new file mode 100644 index 0000000..1b82501 --- /dev/null +++ b/seed/variables.env @@ -0,0 +1 @@ +MONGO_URI=mongodb://localhost:27017/EcommerceUnsaacBD \ No newline at end of file diff --git a/server/server.js b/server/server.js new file mode 100644 index 0000000..19abadb --- /dev/null +++ b/server/server.js @@ -0,0 +1,13 @@ +const path = require('path'); +const express = require('express'); +const app = express(); +const publicPath = path.join(__dirname, '..', 'public'); +const port = process.env.PORT || 4000; +app.use(express.static(publicPath)); +app.get('*', (req, res) => { + res.sendFile(path.join(publicPath, 'index.html')); +}); +app.listen(port, () => { + console.log('Server is up!'); +}); +//aaaaaaaa \ No newline at end of file