2017-01-14 08:50:18 +00:00
|
|
|
const config = require('../config.js')
|
|
|
|
const routes = require('express').Router()
|
2017-01-15 01:36:24 +00:00
|
|
|
const path = require('path')
|
2017-01-14 08:50:18 +00:00
|
|
|
|
2017-01-15 01:36:24 +00:00
|
|
|
routes.get('/', (req, res) => {
|
|
|
|
|
|
|
|
let options = {
|
|
|
|
root: 'pages/',
|
|
|
|
dotfiles: 'deny',
|
|
|
|
headers: {
|
|
|
|
'x-timestamp': Date.now(),
|
|
|
|
'x-sent': true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
res.sendFile('home.html', options, function (err) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err)
|
|
|
|
res.status(err.status).end()
|
|
|
|
} else {
|
|
|
|
console.log('Sent: home.html')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
routes.get('/admin', function (req, res, next) {
|
|
|
|
|
|
|
|
let options = {
|
|
|
|
root: 'pages/admin/',
|
|
|
|
dotfiles: 'deny',
|
|
|
|
headers: {
|
|
|
|
'x-timestamp': Date.now(),
|
|
|
|
'x-sent': true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
res.sendFile('index.html', options, function (err) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err)
|
|
|
|
res.status(err.status).end()
|
|
|
|
} else {
|
|
|
|
console.log('Sent: index.html')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
routes.get('/admin/:name', function (req, res, next) {
|
|
|
|
|
|
|
|
let options = {
|
|
|
|
root: 'pages/admin/',
|
|
|
|
dotfiles: 'deny',
|
|
|
|
headers: {
|
|
|
|
'x-timestamp': Date.now(),
|
|
|
|
'x-sent': true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let fileName = req.params.name
|
|
|
|
|
|
|
|
res.sendFile(fileName, options, function (err) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err)
|
|
|
|
res.status(err.status).end()
|
|
|
|
} else {
|
|
|
|
console.log('Sent:', fileName)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
/*
|
|
|
|
routes.get('/', (req, res) => {
|
|
|
|
res.sendFile('pages/home.html')
|
|
|
|
})
|
|
|
|
|
|
|
|
routes.get('/dashboard', (req, res, next) => {
|
2017-01-14 08:51:56 +00:00
|
|
|
|
2017-01-14 21:13:58 +00:00
|
|
|
if(config.TOKEN !== '')
|
|
|
|
if(req.headers.auth !== config.TOKEN)
|
|
|
|
return res.status(401).send('not-authorized')
|
2017-01-15 01:36:24 +00:00
|
|
|
|
|
|
|
return res.sendFile('pages/home.html')
|
2017-01-14 08:50:18 +00:00
|
|
|
|
2017-01-15 01:36:24 +00:00
|
|
|
})
|
|
|
|
*/
|
2017-01-14 08:50:18 +00:00
|
|
|
|
|
|
|
module.exports = routes
|