mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Lotsa typescript bullshit
This commit is contained in:
parent
b7ac485689
commit
b927988017
65 changed files with 801 additions and 8447 deletions
|
@ -19,27 +19,29 @@
|
|||
------------------------------------------------------------------------- */
|
||||
|
||||
// package requires
|
||||
const express = require('express')
|
||||
const bodyParser = require('body-parser')
|
||||
const busboy = require('connect-busboy')
|
||||
const fs = require('fs')
|
||||
import express from 'express'
|
||||
import bodyParser from 'body-parser'
|
||||
import busboy from 'connect-busboy'
|
||||
import fs from 'fs'
|
||||
const app = express()
|
||||
|
||||
// other requires
|
||||
const logger = require('../../utils/logger.js')
|
||||
const utils = require('../../utils/utils.js')
|
||||
import logger from '../../utils/logger'
|
||||
import utils from '../../utils/utils'
|
||||
import { SetupData } from '../../server'
|
||||
import { ModuleType } from '../../types/basicTypes'
|
||||
|
||||
// stuff gotten from server.js
|
||||
let publicdirs = []
|
||||
|
||||
function GetApp() {
|
||||
const p = publicdirs[0]
|
||||
if (!p) {
|
||||
function GetApp(): ModuleType {
|
||||
const publicdir = publicdirs[0]
|
||||
if (!publicdir) {
|
||||
throw new Error(`No public dir! ( SIO )`)
|
||||
}
|
||||
|
||||
// files in public dirs
|
||||
const uloadFiles = p + 'f'
|
||||
const uloadFiles = publicdir + 'f'
|
||||
|
||||
app.set('view engine', 'ejs')
|
||||
app.set('views', ['./src/modules/sio/views', './src/sharedViews'])
|
||||
|
@ -75,23 +77,22 @@ function GetApp() {
|
|||
})
|
||||
|
||||
function UploadFile(req, res, path, next) {
|
||||
var fstream
|
||||
req.pipe(req.busboy)
|
||||
req.busboy.on('file', function(fieldname, file, filename) {
|
||||
logger.Log('Uploading: ' + filename, logger.GetColor('blue'))
|
||||
|
||||
utils.CreatePath(path, true)
|
||||
let d = new Date()
|
||||
let fn =
|
||||
d.getHours() +
|
||||
const date = new Date()
|
||||
const fn =
|
||||
date.getHours() +
|
||||
'' +
|
||||
d.getMinutes() +
|
||||
date.getMinutes() +
|
||||
'' +
|
||||
d.getSeconds() +
|
||||
date.getSeconds() +
|
||||
'_' +
|
||||
filename
|
||||
|
||||
fstream = fs.createWriteStream(path + '/' + fn)
|
||||
const fstream = fs.createWriteStream(path + '/' + fn)
|
||||
file.pipe(fstream)
|
||||
fstream.on('close', function() {
|
||||
logger.Log(
|
||||
|
@ -107,7 +108,7 @@ function GetApp() {
|
|||
})
|
||||
}
|
||||
|
||||
app.route('/fosuploader').post(function(req, res, next) {
|
||||
app.route('/fosuploader').post(function(req, res) {
|
||||
UploadFile(req, res, uloadFiles, (fn) => {
|
||||
res.redirect('/f/' + fn)
|
||||
})
|
||||
|
@ -125,8 +126,10 @@ function GetApp() {
|
|||
}
|
||||
}
|
||||
|
||||
exports.name = 'Sio'
|
||||
exports.getApp = GetApp
|
||||
exports.setup = (data) => {
|
||||
publicdirs = data.publicdirs
|
||||
export default {
|
||||
name: 'Sio',
|
||||
getApp: GetApp,
|
||||
setup: (data: SetupData): void => {
|
||||
publicdirs = data.publicdirs
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue