lolisafe.js 1005 B

123456789101112131415161718192021222324
  1. const config = require('./config.js')
  2. const api = require('./routes/api.js')
  3. const express = require('express')
  4. const db = require('knex')(config.database)
  5. const fs = require('fs')
  6. const safe = express()
  7. require('./database/db.js')(db, config)
  8. fs.existsSync('./' + config.uploads.folder) || fs.mkdirSync('./' + config.uploads.folder)
  9. fs.existsSync('./' + config.logsFolder) || fs.mkdirSync('./' + config.logsFolder)
  10. safe.enable('trust proxy')
  11. safe.use('/', express.static('./uploads'))
  12. safe.use('/', express.static('./public'))
  13. safe.use('/api', api)
  14. safe.get('/', (req, res, next) => res.sendFile('home.html', { root: './pages/' }))
  15. safe.get('/panel', (req, res, next) => res.sendFile('panel.html', { root: './pages/' }))
  16. safe.use((req, res, next) => res.status(404).sendFile('404.html', { root: './pages/error/' }))
  17. safe.use((req, res, next) => res.status(500).sendFile('500.html', { root: './pages/error/' }))
  18. safe.listen(config.port, () => console.log(`loli-safe started on port ${config.port}`))