aboutsummaryrefslogtreecommitdiff
path: root/lolisafe.js
diff options
context:
space:
mode:
authorkanadeko <[email protected]>2017-01-14 05:50:18 -0300
committerkanadeko <[email protected]>2017-01-14 05:50:18 -0300
commita246fc83658dc10e5da89a8f8f828ca556686860 (patch)
tree462231143aaca715925431339a594242b7ef0b04 /lolisafe.js
parentSmall edit (diff)
downloadhost.fuwn.me-a246fc83658dc10e5da89a8f8f828ca556686860.tar.xz
host.fuwn.me-a246fc83658dc10e5da89a8f8f828ca556686860.zip
Frontend done
Diffstat (limited to 'lolisafe.js')
-rw-r--r--lolisafe.js24
1 files changed, 8 insertions, 16 deletions
diff --git a/lolisafe.js b/lolisafe.js
index c7c0589..fdc7769 100644
--- a/lolisafe.js
+++ b/lolisafe.js
@@ -1,17 +1,22 @@
const config = require('./config.js')
-const routes = require('./routes.js')
+const routes = require('./routes/routes.js')
const express = require('express')
const db = require('knex')(config.database)
const fs = require('fs')
const safe = express()
+require('./database/db.js')(db)
+
fs.existsSync('./' + config.uploads.folder) || fs.mkdirSync('./' + config.uploads.folder)
fs.existsSync('./' + config.logsFolder) || fs.mkdirSync('./' + config.logsFolder)
-fs.existsSync('db') || fs.writeFile('db', '')
safe.enable('trust proxy')
-safe.use('/', express.static('./uploads'))
+let prefix = config.uploads.prefix
+if( prefix !== '' )
+ prefix = prefix + '/'
+
+safe.use('/' + prefix, express.static('./uploads'))
safe.use('/', express.static('./public'))
safe.use('/api' , routes)
@@ -25,17 +30,4 @@ safe.use(function (err, req, res, next) {
res.status(500).end()
})
-// Create the tables we need to store galleries and files
-db.schema.createTableIfNotExists('gallery', function (table) {
- table.increments()
- table.string('name')
- table.timestamps()
-}).then(() => {})
-
-db.schema.createTableIfNotExists('files', function (table) {
- table.increments()
- table.string('file')
- table.integer('galleryid')
-}).then(() => {})
-
safe.listen(config.port, () => console.log(`loli-safe started on port ${config.port}`)) \ No newline at end of file