This commit is contained in:
Sergey Yarkov 2020-01-15 20:52:01 +03:00
parent 3d60cf0bbe
commit aed9bbcaaa
7 changed files with 11 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules
package-lock.json
.env

View File

@ -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'
}

View File

@ -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);
});

View File

@ -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}" нет в наличии`);
}

View File

@ -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...');
});
});

View File

@ -508,7 +508,6 @@ footer.main-footer .container {
.main-section .background {
background-color: #fff;
padding: 40px;
margin: 40px 0;
min-height: 650px;
}

View File

@ -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"
},