{"size": 1958, "ext": "js", "max_stars_repo_path": "src/server.js", "max_stars_repo_name": "merlox/bucky", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/server.js", "max_issues_repo_name": "merlox/bucky", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/server.js", "max_forks_repo_name": "merlox/bucky", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.1066666667, "max_line_length": 89, "alphanum_fraction": 0.646578141}
const express = require('express')
const bodyParser = require('body-parser')
const path = require('path')
const app = express()
const functions = require('./server/functions.js')
const fileUpload = require('express-fileupload')
const port = 8123

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: true}))
app.use(express.static(path.join(__dirname, 'public', 'dist')))
app.use(express.static(path.join(__dirname, 'public', 'dist', 'imgs')))
app.use(fileUpload())

// Logger middleware
app.use('*', (req, res, next) => {
    console.log(`\nRequesting: ${req.originalUrl} from ${req.ip}`)
    next()
})

app.get('/check-access', (req, res) => {
    functions.checkAccess(req, res)
})

app.get('/get-files', (req, res) => {
    functions.getFiles(req, res)
})

app.get('/get-account-type', (req, res) => {
    functions.getAccountType(req, res)
})

app.post('/register-new', (req, res) => {
    functions.registerNew(req, res)
})

app.post('/upload-file', (req, res) => {
    functions.uploadFile(req, res)
})

app.post('/edit-file', (req, res) => {
    functions.editFile(req, res)
})

app.get('/delete-file', (req, res) => {
    functions.deleteFile(req, res)
})


app.get('*/build.js', (req, res) => {
    return res.sendFile(path.join(__dirname, 'public/dist/build.js'))
})

app.get('*/datepicker.js', (req, res) => {
    return res.sendFile(path.join(__dirname, 'public/dist/datepicker', 'datepicker.js'))
})

app.get('*/datepicker.css', (req, res) => {
    return res.sendFile(path.join(__dirname, 'public/dist/datepicker', 'datepicker.css'))
})

// Send the build file for sub-urls
app.get('*/imgs/:image', (req, res) => {
    return res.sendFile(path.join(__dirname, 'public/dist/imgs', req.params.image))
})

// To send the index
app.get('*', (req, res) => {
    return res.sendFile(path.join(__dirname, 'public/dist/index.html'))
})

app.listen(port, '0.0.0.0', () => {
    console.log(`Server listening on 13.59.158.99:${port}`)
})
