16
README.md
|
|
@ -11,10 +11,11 @@ thatbeing said goodluck.
|
|||
from heere is will assume you have set up the api server
|
||||
|
||||
if deploying to a serverless application make sure you se t the environmental variables forst. these are as follwos
|
||||
* BANKAPIURL=<your api url including http/s and the trailing slash NOT BANKF>
|
||||
* SECURE=<true if you have ssl on your front end host>
|
||||
* PORT=<put the port in here>
|
||||
* SETUP=<true when you have set the above this just gets rid of the setup page that will show if it equals false or the .env file is not fojound>
|
||||
* BANKAPIURL=your api url including http/s and the trailing slash NOT BANKF
|
||||
* SECURE=true if you have ssl on your front end host
|
||||
* PORT=put the port in here
|
||||
* MONGO=put your mongodb url here
|
||||
* SETUP=true when you have set the above this just gets rid of the setup page that will show if it equals false or the .env file is not fojound
|
||||
|
||||
if you are deploying on a vps then
|
||||
1. git clone repository
|
||||
|
|
@ -22,3 +23,10 @@ if you are deploying on a vps then
|
|||
1. run with your favourite node webserver if you dont know any use [pm2](https://pm2.keymetrics.io/)
|
||||
1. go through set up at localhost:<port number you set earlier>
|
||||
1. restart the application and badda bim badda boom you done
|
||||
|
||||
## Marketplace
|
||||
|
||||
now this is getting complex :sunglasses:
|
||||
the market place is new and requires monogodb until Jolly finishes his rust api marketplace and i can integrate that
|
||||
set up is pretty straight forward for now, it should just work:tm: as long as you import all the minecraft blocks into the database as per the item schema,
|
||||
to do this there is a bit of code at the bottom of ./routes/marketplace.js uncomment that and run that url then comment it again cause you dont want to run it twice, it will messy up your shit. i will make it a one time run route in the future.
|
||||
|
|
|
|||
71
index.js
|
|
@ -14,6 +14,7 @@ const url = require('url')
|
|||
const dotenv = require('dotenv');
|
||||
const fs = require('fs');
|
||||
let Log = require('./schemas/log.js');
|
||||
const mongoose = require('mongoose')
|
||||
dotenv.config();
|
||||
//mongodb connection
|
||||
|
||||
|
|
@ -64,25 +65,48 @@ app.use(expressValidator({
|
|||
}
|
||||
}));
|
||||
app.post('/setup', async function(req, res){
|
||||
|
||||
|
||||
console.log(req.body)
|
||||
let mongo = req.body.mongo;
|
||||
let {mongo, url, banksecure, marketplace} = req.body;
|
||||
process.env.MONGO = mongo
|
||||
let apiurl = 'BANKAPIURL='+req.body.url
|
||||
process.env.BANKAPIURL = req.body.url
|
||||
let banksecure = 'SECURE=false'
|
||||
process.env.MARKETPLACE = false
|
||||
if(marketplace){
|
||||
process.env.MARKETPLACE = true
|
||||
}
|
||||
if(!url.endsWith('/')){
|
||||
url=url+"/"
|
||||
}
|
||||
process.env.BANKAPIURL =url
|
||||
process.env.SECURE = false
|
||||
if(req.body.secure){
|
||||
banksecure = 'SECURE=true'
|
||||
process.env.SECURE = true
|
||||
if(!banksecure){
|
||||
banksecure = false
|
||||
process.env.SECURE = false
|
||||
}
|
||||
process.env.SETUP = true
|
||||
fs.writeFileSync('.env', apiurl+'\n'+banksecure+'\n'+mongo+'\nSETUP=true')
|
||||
fs.writeFileSync('.env', "BANKAPIURL="+process.env.BANKAPIURL+'\n'+"SECURE="+process.env.SECURE+'\n'+"MARKETPLACE="+process.env.MARKETPLACE+'\n'+"MONGO="+process.env.MONGO+'\nSETUP=true')
|
||||
dotenv.config();
|
||||
if(process.env.MARKETPLACE){
|
||||
mongoose.connect(process.env.MONGO,{
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
useFindAndModify: true,
|
||||
});
|
||||
|
||||
let db = mongoose.connection;
|
||||
db.once('open', function(){
|
||||
console.log('Connected to MongoDB');
|
||||
})
|
||||
|
||||
//check for DB errors
|
||||
db.on('error', function(err){
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
res.redirect('/')
|
||||
})
|
||||
app.get('/', async function(req, res){
|
||||
if(setup==false){
|
||||
if(!process.env.SETUP){
|
||||
res.render('setup')
|
||||
}else{
|
||||
|
||||
|
|
@ -105,7 +129,8 @@ app.get('/', async function(req, res){
|
|||
res.render('index', {
|
||||
user: req.session.user,
|
||||
admin: req.session.admin,
|
||||
alive: alive
|
||||
alive: alive,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
@ -153,8 +178,8 @@ app.get('/BankF', ensureAuthenticated, async function(req, res){
|
|||
console.log(logrec.timings)
|
||||
console.log("query finished "+Date.now())
|
||||
logsent = logsent.body.value
|
||||
console.log(logsent)
|
||||
if(logsent === 1 || logsent === -1 || logsent == null){
|
||||
|
||||
if(logsent == 1 || logsent == -1 || logsent == null){
|
||||
logsent = undefined
|
||||
}else{
|
||||
logsent = await logsent.filter(({ from }) => from === req.session.user)
|
||||
|
|
@ -180,6 +205,7 @@ app.get('/BankF', ensureAuthenticated, async function(req, res){
|
|||
user: req.session.user,
|
||||
admin: req.session.admin,
|
||||
sucesses: successes,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
});
|
||||
|
||||
|
|
@ -268,12 +294,14 @@ app.post('/sendfunds', async function(req, res){
|
|||
balance:balance.value,
|
||||
user: req.session.user,
|
||||
admin: req.session.admin,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
app.post('/register', async function(req, res){
|
||||
var {name, password, password2} = req.body;
|
||||
|
||||
let checkuser = await got(process.env.BANKAPIURL+'BankF/contains/'+name)
|
||||
checkuser = JSON.parse(checkuser.body).value
|
||||
let errors = [];
|
||||
|
|
@ -290,7 +318,8 @@ app.post('/register', async function(req, res){
|
|||
}
|
||||
if(errors[0]){
|
||||
res.render('register', {
|
||||
errors:errors
|
||||
errors:errors,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
} else {
|
||||
if(postUser(name, password)){
|
||||
|
|
@ -298,6 +327,7 @@ app.post('/register', async function(req, res){
|
|||
res.render('login',{
|
||||
errors:errors,
|
||||
successes: successes,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -305,6 +335,7 @@ app.post('/register', async function(req, res){
|
|||
errors.push({msg: "User already exists"})
|
||||
res.render('register',{
|
||||
errors:errors,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
@ -326,6 +357,7 @@ app.post('/login', async function(req, res){
|
|||
} catch(err){
|
||||
console.log(err)
|
||||
}
|
||||
req.session.password = password
|
||||
if(adminTest.body.value == undefined){
|
||||
res.redirect('/')
|
||||
}else{
|
||||
|
|
@ -350,7 +382,8 @@ app.post('/login', async function(req, res){
|
|||
if(verified.body.value == 0){
|
||||
errors.push({msg: 'Password wrong'})
|
||||
res.render('login',{
|
||||
errors:errors
|
||||
errors:errors,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
}else if(verified.body.value == 1){
|
||||
req.session.user = name;
|
||||
|
|
@ -359,7 +392,8 @@ app.post('/login', async function(req, res){
|
|||
} else {
|
||||
errors.push({msg: 'User not found'})
|
||||
res.render('login',{
|
||||
errors:errors
|
||||
errors:errors,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -377,13 +411,14 @@ app.use('/admin', admin);
|
|||
let settings = require('./routes/settings');
|
||||
app.use('/settings', settings)
|
||||
|
||||
|
||||
|
||||
let marketplace = require('./routes/marketplace')
|
||||
app.use('/marketplace', marketplace)
|
||||
|
||||
|
||||
app.get('/logout', function(req, res){
|
||||
req.session.regenerate(function(err) {
|
||||
res.render('login', {
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
})
|
||||
});
|
||||
|
|
@ -393,6 +428,7 @@ app.get('/login', function(req, res){
|
|||
req.session.regenerate(function(err) {
|
||||
res.render('login', {
|
||||
user: req.session.user,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
})
|
||||
});
|
||||
|
|
@ -401,6 +437,7 @@ app.get('/register', function(req, res){
|
|||
res.render('register', {
|
||||
user: req.session.user,
|
||||
admin: req.session.admin,
|
||||
marketplace: process.env.MARKETPLACE
|
||||
})
|
||||
|
||||
});
|
||||
|
|
|
|||
925
package-lock.json
generated
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"connect-flash": "^0.1.1",
|
||||
"cote": "^1.0.2",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"express-messages": "^1.0.1",
|
||||
|
|
@ -12,6 +13,7 @@
|
|||
"mongoose": "^5.12.5",
|
||||
"path": "^0.12.7",
|
||||
"pug": "^3.0.2",
|
||||
"socket.io": "^2.4.1",
|
||||
"url": "^0.11.0",
|
||||
"validator": "^13.5.2"
|
||||
},
|
||||
|
|
|
|||
BIN
public/blockimages/items/0-0.png
Normal file
|
After Width: | Height: | Size: 80 B |
BIN
public/blockimages/items/1-0.png
Normal file
|
After Width: | Height: | Size: 454 B |
BIN
public/blockimages/items/1-1.png
Normal file
|
After Width: | Height: | Size: 1,009 B |
BIN
public/blockimages/items/1-2.png
Normal file
|
After Width: | Height: | Size: 943 B |
BIN
public/blockimages/items/1-3.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/blockimages/items/1-4.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/blockimages/items/1-5.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/blockimages/items/1-6.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/blockimages/items/10-0.png
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
public/blockimages/items/100-0.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/blockimages/items/101-0.png
Normal file
|
After Width: | Height: | Size: 593 B |
BIN
public/blockimages/items/102-0.png
Normal file
|
After Width: | Height: | Size: 180 B |
BIN
public/blockimages/items/103-0.png
Normal file
|
After Width: | Height: | Size: 908 B |
BIN
public/blockimages/items/104-0.png
Normal file
|
After Width: | Height: | Size: 172 B |
BIN
public/blockimages/items/105-0.png
Normal file
|
After Width: | Height: | Size: 172 B |
BIN
public/blockimages/items/106-0.png
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
public/blockimages/items/107-0.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/blockimages/items/108-0.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/blockimages/items/109-0.png
Normal file
|
After Width: | Height: | Size: 586 B |
BIN
public/blockimages/items/11-0.png
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
public/blockimages/items/110-0.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
public/blockimages/items/111-0.png
Normal file
|
After Width: | Height: | Size: 209 B |
BIN
public/blockimages/items/112-0.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
public/blockimages/items/113-0.png
Normal file
|
After Width: | Height: | Size: 482 B |
BIN
public/blockimages/items/114-0.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/blockimages/items/115-0.png
Normal file
|
After Width: | Height: | Size: 558 B |
BIN
public/blockimages/items/116-0.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/blockimages/items/117-0.png
Normal file
|
After Width: | Height: | Size: 937 B |
BIN
public/blockimages/items/118-0.png
Normal file
|
After Width: | Height: | Size: 918 B |
BIN
public/blockimages/items/119-0.png
Normal file
|
After Width: | Height: | Size: 802 B |
BIN
public/blockimages/items/12-0.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
public/blockimages/items/12-1.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/blockimages/items/120-0.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/blockimages/items/121-0.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
public/blockimages/items/122-0.png
Normal file
|
After Width: | Height: | Size: 328 B |
BIN
public/blockimages/items/123-0.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/blockimages/items/124-0.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/blockimages/items/125-0.png
Normal file
|
After Width: | Height: | Size: 530 B |
BIN
public/blockimages/items/125-1.png
Normal file
|
After Width: | Height: | Size: 548 B |
BIN
public/blockimages/items/125-2.png
Normal file
|
After Width: | Height: | Size: 563 B |
BIN
public/blockimages/items/125-3.png
Normal file
|
After Width: | Height: | Size: 541 B |
BIN
public/blockimages/items/125-4.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/blockimages/items/125-5.png
Normal file
|
After Width: | Height: | Size: 981 B |
BIN
public/blockimages/items/126-0.png
Normal file
|
After Width: | Height: | Size: 412 B |
BIN
public/blockimages/items/126-1.png
Normal file
|
After Width: | Height: | Size: 432 B |
BIN
public/blockimages/items/126-2.png
Normal file
|
After Width: | Height: | Size: 449 B |
BIN
public/blockimages/items/126-3.png
Normal file
|
After Width: | Height: | Size: 433 B |
BIN
public/blockimages/items/126-4.png
Normal file
|
After Width: | Height: | Size: 997 B |
BIN
public/blockimages/items/126-5.png
Normal file
|
After Width: | Height: | Size: 802 B |
BIN
public/blockimages/items/127-0.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/blockimages/items/128-0.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
public/blockimages/items/129-0.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/blockimages/items/13-0.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/blockimages/items/130-0.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
public/blockimages/items/131-0.png
Normal file
|
After Width: | Height: | Size: 871 B |
BIN
public/blockimages/items/132-0.png
Normal file
|
After Width: | Height: | Size: 145 B |
BIN
public/blockimages/items/133-0.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/blockimages/items/134-0.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/blockimages/items/135-0.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/blockimages/items/136-0.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/blockimages/items/137-0.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/blockimages/items/138-0.png
Normal file
|
After Width: | Height: | Size: 707 B |
BIN
public/blockimages/items/139-0.png
Normal file
|
After Width: | Height: | Size: 491 B |
BIN
public/blockimages/items/139-1.png
Normal file
|
After Width: | Height: | Size: 974 B |
BIN
public/blockimages/items/14-0.png
Normal file
|
After Width: | Height: | Size: 561 B |
BIN
public/blockimages/items/140-0.png
Normal file
|
After Width: | Height: | Size: 634 B |
BIN
public/blockimages/items/141-0.png
Normal file
|
After Width: | Height: | Size: 518 B |
BIN
public/blockimages/items/142-0.png
Normal file
|
After Width: | Height: | Size: 320 B |
BIN
public/blockimages/items/143-0.png
Normal file
|
After Width: | Height: | Size: 187 B |
BIN
public/blockimages/items/144-0.png
Normal file
|
After Width: | Height: | Size: 422 B |
BIN
public/blockimages/items/145-0.png
Normal file
|
After Width: | Height: | Size: 726 B |
BIN
public/blockimages/items/146-0.png
Normal file
|
After Width: | Height: | Size: 934 B |
BIN
public/blockimages/items/147-0.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/blockimages/items/148-0.png
Normal file
|
After Width: | Height: | Size: 364 B |
BIN
public/blockimages/items/149-0.png
Normal file
|
After Width: | Height: | Size: 311 B |
BIN
public/blockimages/items/15-0.png
Normal file
|
After Width: | Height: | Size: 561 B |
BIN
public/blockimages/items/150-0.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
public/blockimages/items/151-0.png
Normal file
|
After Width: | Height: | Size: 385 B |
BIN
public/blockimages/items/152-0.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/blockimages/items/153-0.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
public/blockimages/items/154-0.png
Normal file
|
After Width: | Height: | Size: 233 B |
BIN
public/blockimages/items/155-0.png
Normal file
|
After Width: | Height: | Size: 796 B |
BIN
public/blockimages/items/155-1.png
Normal file
|
After Width: | Height: | Size: 830 B |
BIN
public/blockimages/items/155-2.png
Normal file
|
After Width: | Height: | Size: 680 B |
BIN
public/blockimages/items/156-0.png
Normal file
|
After Width: | Height: | Size: 785 B |
BIN
public/blockimages/items/157-0.png
Normal file
|
After Width: | Height: | Size: 287 B |
BIN
public/blockimages/items/158-0.png
Normal file
|
After Width: | Height: | Size: 736 B |
BIN
public/blockimages/items/159-0.png
Normal file
|
After Width: | Height: | Size: 978 B |
BIN
public/blockimages/items/159-1.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
public/blockimages/items/159-10.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
public/blockimages/items/159-11.png
Normal file
|
After Width: | Height: | Size: 826 B |
BIN
public/blockimages/items/159-12.png
Normal file
|
After Width: | Height: | Size: 856 B |
BIN
public/blockimages/items/159-13.png
Normal file
|
After Width: | Height: | Size: 843 B |
BIN
public/blockimages/items/159-14.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
public/blockimages/items/159-15.png
Normal file
|
After Width: | Height: | Size: 723 B |
BIN
public/blockimages/items/159-2.png
Normal file
|
After Width: | Height: | Size: 1 KiB |