migrated `ass.js` to `ass.ts`, why tf was this the easy one to migrate?!

pull/62/head
tycrek 3 years ago
parent 11ce9c228e
commit 589c85d7e5
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

13
package-lock.json generated

@ -45,6 +45,7 @@
"@types/ffmpeg-static": "^3.0.0",
"@types/fs-extra": "^9.0.12",
"@types/luxon": "^2.0.3",
"@types/marked": "^3.0.0",
"@types/node": "^16.9.0",
"@types/node-fetch": "^2.5.12",
"@types/stream-to-array": "^2.3.0",
@ -801,6 +802,12 @@
"integrity": "sha512-qhyivlWLuSnQa6EMx7W2oPiMUD4/F9BLuQynZe3jBgmfCS6Xr+Ock1+ZotN6xEkdJvdckyX+z1r5fyvi31GV5Q==",
"dev": true
},
"node_modules/@types/marked": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/marked/-/marked-3.0.0.tgz",
"integrity": "sha512-vof90OIWT+Tzq3MBRXgV9fsH8PC3WZ4OQg9Qa04vOtP0TcyiNfl7BTonYCmTapHZ5lRZh6ihUYkAy7St1hmk/A==",
"dev": true
},
"node_modules/@types/mime": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
@ -5306,6 +5313,12 @@
"integrity": "sha512-qhyivlWLuSnQa6EMx7W2oPiMUD4/F9BLuQynZe3jBgmfCS6Xr+Ock1+ZotN6xEkdJvdckyX+z1r5fyvi31GV5Q==",
"dev": true
},
"@types/marked": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/marked/-/marked-3.0.0.tgz",
"integrity": "sha512-vof90OIWT+Tzq3MBRXgV9fsH8PC3WZ4OQg9Qa04vOtP0TcyiNfl7BTonYCmTapHZ5lRZh6ihUYkAy7St1hmk/A==",
"dev": true
},
"@types/mime": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",

@ -72,6 +72,7 @@
"@types/ffmpeg-static": "^3.0.0",
"@types/fs-extra": "^9.0.12",
"@types/luxon": "^2.0.3",
"@types/marked": "^3.0.0",
"@types/node": "^16.9.0",
"@types/node-fetch": "^2.5.12",
"@types/stream-to-array": "^2.3.0",

@ -1,3 +1,5 @@
import { AssRequest, AssResponse, ErrWrap } from './definitions';
let doSetup = null;
try {
// Check if config.json exists
@ -7,23 +9,20 @@ try {
}
// Run first time setup if using Docker (pseudo-process, setup will be run with docker exec)
if (doSetup) {
doSetup();
return;
}
if (doSetup) doSetup();
// Load the config
const { host, port, useSsl, isProxied, s3enabled, frontendName, indexFile } = require('../config.json');
//#region Imports
const fs = require('fs-extra');
const express = require('express');
import fs from 'fs-extra';
import express from 'express';
const nofavicon = require('@tycrek/express-nofavicon');
const helmet = require('helmet');
const marked = require('marked');
const uploadRouter = require('./routers/upload');
const resourceRouter = require('./routers/resource');
const { path, log, getTrueHttp, getTrueDomain } = require('./utils');
import helmet from 'helmet';
import marked from 'marked';
import uploadRouter from './routers/upload';
import resourceRouter from './routers/resource';
import { path, log, getTrueHttp, getTrueDomain } from './utils';
const { CODE_INTERNAL_SERVER_ERROR } = require('../MagicNumbers.json');
const { name: ASS_NAME, version: ASS_VERSION } = require('../package.json');
//#endregion
@ -71,7 +70,7 @@ app.get('/', (req, res, next) => ASS_INDEX // skipcq: JS-0229
? ASS_INDEX(req, res, next)
: fs.readFile(path('README.md'))
.then((bytes) => bytes.toString())
.then(marked)
.then((data) => marked(data))
.then((d) => res.render('index', { data: d }))
.catch(next));
@ -83,10 +82,10 @@ const ASS_FRONTEND = fs.existsSync(path(`./${frontendName}/package.json`)) ? (re
ASS_FRONTEND.enabled && app.use(ASS_FRONTEND.endpoint, ASS_FRONTEND.router); // skipcq: JS-0093
// '/:resouceId' always needs to be LAST since it's a catch-all route
app.use('/:resourceId', (req, _res, next) => (req.resourceId = req.params.resourceId, next()), ROUTERS.resource); // skipcq: JS-0086, JS-0090
app.use('/:resourceId', (req: AssRequest, _res, next) => (req.resourceId = req.params.resourceId, next()), ROUTERS.resource); // skipcq: JS-0086, JS-0090
// Error handler
app.use((err, _req, res, _next) => log.error(err).err(err).callback(() => res.sendStatus(CODE_INTERNAL_SERVER_ERROR))); // skipcq: JS-0128
app.use((err: ErrWrap, _req: AssRequest, res: AssResponse, _next: Function) => log.error(err).err(err).callback(() => res.sendStatus(CODE_INTERNAL_SERVER_ERROR))); // skipcq: JS-0128
// Host the server
log

@ -124,4 +124,4 @@ router.get('/delete/:deleteId', (req: AssRequest, res: AssResponse, next) => {
.catch(next);
});
module.exports = router;
export default router;

@ -124,4 +124,4 @@ router.post('/', (req: AssRequest, res: AssResponse, next: Function) => {
}).catch(next);
});
module.exports = router;
export default router;

@ -262,7 +262,7 @@ function doSetup() {
// Complete & exit
.then(() => log.blank().success('Setup complete').callback(() => process.exit(0)))
.catch((err) => log.blank().error(err));
.catch((err) => log.blank().error(err).callback(() => process.exit(1)));
}
module.exports = {

Loading…
Cancel
Save