diff --git a/.gitignore b/.gitignore index 25c8fdb..8f5e467 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -package-lock.json \ No newline at end of file +package-lock.json +.env \ No newline at end of file diff --git a/config/database.js b/config/database.js index 1d2a124..e12a148 100644 --- a/config/database.js +++ b/config/database.js @@ -1,4 +1,4 @@ module.exports = { - url: 'mongodb+srv://ds_user1:zBD4b6kQbKAK2ar@cluster0-vtuzl.mongodb.net/test?retryWrites=true', + url: process.env.DATABASE_URI, name: 'digital_store' } \ No newline at end of file diff --git a/config/routes/api.js b/config/routes/api.js index 3d8c158..5d811cd 100644 --- a/config/routes/api.js +++ b/config/routes/api.js @@ -126,7 +126,7 @@ module.exports = function(server, db) { category.length > 0 ? res.send(category) : res.send({error: 'Такой категории не существует.'}); }); - server.get('/api/icons', (req, res) => { + server.get('/api/icons', checkAuthenticated, (req, res) => { const icons = fs.readdirSync('dist/public/img/service-icons'); res.json(icons); }); diff --git a/config/routes/payments/qiwi.payment.js b/config/routes/payments/qiwi.payment.js index 2774a03..106f7a2 100644 --- a/config/routes/payments/qiwi.payment.js +++ b/config/routes/payments/qiwi.payment.js @@ -27,7 +27,10 @@ module.exports = function(server, db, qiwiApi) { } qiwiApi.createBill(billId, fields).then((data) => { res.send(data); - }); + }) + .catch(() => { + res.send('Произошла ошибка при создании заказа. Попробуйте позже.'); + }) } else { res.send(`Товара "${req.body.items[empty].title}" нет в наличии`); } diff --git a/config/server.js b/config/server.js index 05a657c..fb80c7a 100644 --- a/config/server.js +++ b/config/server.js @@ -16,8 +16,7 @@ const methodOverride = require('method-override'); const multer = require('multer'); const QiwiBillPaymentsAPI = require('@qiwi/bill-payments-node-js-sdk'); -const SECRET_KEY = '.'; -const qiwiApi = new QiwiBillPaymentsAPI(SECRET_KEY); +const qiwiApi = new QiwiBillPaymentsAPI(process.env.QIWI_SECRET_KEY); MongoClient.connect(db_config.url, {useNewUrlParser: true, useUnifiedTopology: true}) .then((client) => { @@ -65,6 +64,6 @@ MongoClient.connect(db_config.url, {useNewUrlParser: true, useUnifiedTopology: t .finally(() => { const port = process.env.PORT || 3000; server.listen(port, () => { - console.log('Listen port 3000...'); + console.log('App is running...'); }); }); diff --git a/dist/public/css/style.css b/dist/public/css/style.css index b61bc5c..1cdcbcf 100644 --- a/dist/public/css/style.css +++ b/dist/public/css/style.css @@ -508,7 +508,6 @@ footer.main-footer .container { .main-section .background { background-color: #fff; padding: 40px; - margin: 40px 0; min-height: 650px; } diff --git a/package.json b/package.json index 1e44261..b24ea87 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "main": "index.js", "scripts": { + "start": "node config/server.js", "build": "webpack --mode production", "wp-server": "webpack-dev-server --mode development" },