Remove extra FS import.

merge-requests/6/head
knotteye 2019-12-05 16:19:07 -06:00
parent 76c63d3a94
commit 3f26790878
1 changed files with 2 additions and 3 deletions

View File

@ -1,7 +1,6 @@
import * as express from "express"; import * as express from "express";
import * as njk from "nunjucks"; import * as njk from "nunjucks";
import * as bodyparser from "body-parser"; import * as bodyparser from "body-parser";
import * as fs from "fs";
import * as socketio from "socket.io"; import * as socketio from "socket.io";
import * as http from "http"; import * as http from "http";
import * as cookies from "cookie-parser"; import * as cookies from "cookie-parser";
@ -9,7 +8,7 @@ import * as dirty from "dirty";
import * as api from "./api"; import * as api from "./api";
import * as db from "./database"; import * as db from "./database";
import * as irc from "./irc"; import * as irc from "./irc";
import { readFileSync, writeFileSync } from "fs"; import { readdir, readFileSync, writeFileSync } from "fs";
import { JWT, JWK } from "jose"; import { JWT, JWK } from "jose";
import { strict } from "assert"; import { strict } from "assert";
import { parse } from "path"; import { parse } from "path";
@ -280,7 +279,7 @@ async function initSite(openReg) {
app.get('/vods/:user', (req, res) => { app.get('/vods/:user', (req, res) => {
db.query('select username from user_meta where username='+db.raw.escape(req.params.user)).then((result) => { db.query('select username from user_meta where username='+db.raw.escape(req.params.user)).then((result) => {
if(result[0]){ if(result[0]){
fs.readdir('./site/live/'+result[0].username, {withFileTypes: true} , (err, files) => { readdir('./site/live/'+result[0].username, {withFileTypes: true} , (err, files) => {
if(tryDecode(req.cookies.Authorization)) { if(tryDecode(req.cookies.Authorization)) {
res.render('vods.njk', Object.assign({user: result[0].username, list: files.filter(fn => fn.name.endsWith('.mp4'))}, {auth: {is: true, name: JWT.decode(req.cookies.Authorization)['username']}}, njkconf)); res.render('vods.njk', Object.assign({user: result[0].username, list: files.filter(fn => fn.name.endsWith('.mp4'))}, {auth: {is: true, name: JWT.decode(req.cookies.Authorization)['username']}}, njkconf));
} }