aboutsummaryrefslogtreecommitdiff
path: root/lolisafe.js
blob: f99df789c3434032de103b7237ed06139485c212 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const config = require('./config.js')
const routes = require('./routes.js')
const express = require('express')
const db = require('knex')(config.database)
const fs = require('fs')
const safe = express()

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.use('/', express.static('./uploads'))
safe.use('/api'  , routes)
safe.use('/panel', express.static('./dashboard'))

// 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.enable('trust proxy')

safe.listen(config.port, () => console.log(`loli-safe started on port ${config.port}`))