diff --git a/src/SlugGenerator.ts b/src/SlugGenerator.ts index d13b2a6..0487c45 100644 --- a/src/SlugGenerator.ts +++ b/src/SlugGenerator.ts @@ -1,7 +1,8 @@ import config from "config"; -import FileModel from "./models/FileModel"; -import {ServerError} from "swaf/HttpError"; import {nanoid} from "nanoid"; +import {ServerError} from "swaf/HttpError"; + +import FileModel from "./models/FileModel.js"; export default async function generateSlug(tries: number): Promise { let i = 0; diff --git a/src/controllers/AboutController.ts b/src/controllers/AboutController.ts index 4b92b19..528b580 100644 --- a/src/controllers/AboutController.ts +++ b/src/controllers/AboutController.ts @@ -1,5 +1,5 @@ -import Controller from "swaf/Controller"; import {Request, Response} from "express"; +import Controller from "swaf/Controller"; export default class AboutController extends Controller { public routes(): void { diff --git a/src/controllers/LinkController.ts b/src/controllers/LinkController.ts index ef1057d..f8081dd 100644 --- a/src/controllers/LinkController.ts +++ b/src/controllers/LinkController.ts @@ -1,17 +1,18 @@ -import Controller from "swaf/Controller"; -import {NextFunction, Request, Response} from "express"; -import {BadRequestError, NotFoundHttpError, ServerError} from "swaf/HttpError"; import config from "config"; -import {RequireRequestAuthMiddleware} from "swaf/auth/AuthComponent"; -import URLRedirect from "../models/URLRedirect"; -import URLRedirectController from "./URLRedirectController"; -import FileModel from "../models/FileModel"; -import generateSlug from "../SlugGenerator"; -import FileController, {FileUploadFormMiddleware} from "./FileController"; +import {NextFunction, Request, Response} from "express"; import * as fs from "fs"; -import {encodeRFC5987ValueChars} from "../Utils"; -import {promisify} from "util"; +import {RequireRequestAuthMiddleware} from "swaf/auth/AuthComponent"; +import Controller from "swaf/Controller"; +import {BadRequestError, NotFoundHttpError, ServerError} from "swaf/HttpError"; import {logger} from "swaf/Logger"; +import {promisify} from "util"; + +import FileModel from "../models/FileModel.js"; +import URLRedirect from "../models/URLRedirect.js"; +import generateSlug from "../SlugGenerator.js"; +import {encodeRFC5987ValueChars} from "../Utils.js"; +import FileController, {FileUploadFormMiddleware} from "./FileController.js"; +import URLRedirectController from "./URLRedirectController.js"; export default class LinkController extends Controller { public routes(): void { @@ -75,7 +76,13 @@ export default class LinkController extends Controller { protected async putFile(req: Request, res: Response, next: NextFunction): Promise { if (req.body.type !== 'file') return next(); const slug = req.params.slug; - if (!slug) throw new BadRequestError('Cannot put without a slug.', 'Either provide a slug or use POST method instead.', req.url); + if (!slug) { + throw new BadRequestError( + 'Cannot put without a slug.', + 'Either provide a slug or use POST method instead.', + req.url, + ); + } await FileController.handleFileUpload(slug, req, res, true); } diff --git a/src/migrations/CreateAuthTokensTable.ts b/src/migrations/CreateAuthTokensTable.ts index ea81d77..7a0452a 100644 --- a/src/migrations/CreateAuthTokensTable.ts +++ b/src/migrations/CreateAuthTokensTable.ts @@ -1,6 +1,7 @@ import Migration from "swaf/db/Migration"; import ModelFactory from "swaf/db/ModelFactory"; -import AuthToken from "../models/AuthToken"; + +import AuthToken from "../models/AuthToken.js"; export default class CreateAuthTokensTable extends Migration { public async install(): Promise { diff --git a/src/migrations/CreateFilesTable.ts b/src/migrations/CreateFilesTable.ts index f45516f..e84c89d 100644 --- a/src/migrations/CreateFilesTable.ts +++ b/src/migrations/CreateFilesTable.ts @@ -1,6 +1,7 @@ import Migration from "swaf/db/Migration"; import ModelFactory from "swaf/db/ModelFactory"; -import FileModel from "../models/FileModel"; + +import FileModel from "../models/FileModel.js"; export default class CreateFilesTable extends Migration { public async install(): Promise { diff --git a/src/migrations/CreateUrlRedirectsTable.ts b/src/migrations/CreateUrlRedirectsTable.ts index 249e51a..57b086b 100644 --- a/src/migrations/CreateUrlRedirectsTable.ts +++ b/src/migrations/CreateUrlRedirectsTable.ts @@ -1,6 +1,7 @@ import Migration from "swaf/db/Migration"; import ModelFactory from "swaf/db/ModelFactory"; -import URLRedirect from "../models/URLRedirect"; + +import URLRedirect from "../models/URLRedirect.js"; export default class CreateUrlRedirectsTable extends Migration { public async install(): Promise { diff --git a/src/migrations/ReplaceTtlWithExpiresAtFilesTable.ts b/src/migrations/ReplaceTtlWithExpiresAtFilesTable.ts index 722d853..ef745ab 100644 --- a/src/migrations/ReplaceTtlWithExpiresAtFilesTable.ts +++ b/src/migrations/ReplaceTtlWithExpiresAtFilesTable.ts @@ -1,5 +1,6 @@ import Migration from "swaf/db/Migration"; -import FileModel from "../models/FileModel"; + +import FileModel from "../models/FileModel.js"; export default class ReplaceTtlWithExpiresAtFilesTable extends Migration { public async install(): Promise { diff --git a/src/models/AuthToken.ts b/src/models/AuthToken.ts index 8e1465c..329a85d 100644 --- a/src/models/AuthToken.ts +++ b/src/models/AuthToken.ts @@ -1,7 +1,7 @@ -import Model from "swaf/db/Model"; +import {nanoid} from "nanoid"; import AuthProof from "swaf/auth/AuthProof"; import User from "swaf/auth/models/User"; -import {nanoid} from "nanoid"; +import Model from "swaf/db/Model"; export default class AuthToken extends Model implements AuthProof { public id?: number = undefined; diff --git a/src/models/URLRedirect.ts b/src/models/URLRedirect.ts index 8e01dd9..acf06a8 100644 --- a/src/models/URLRedirect.ts +++ b/src/models/URLRedirect.ts @@ -2,10 +2,9 @@ import config from "config"; import {Request} from "express"; import User from "swaf/auth/models/User"; import {route} from "swaf/common/Routing"; -import Controller from "swaf/Controller"; import Model from "swaf/db/Model"; -import FileModel from "./FileModel"; +import FileModel from "./FileModel.js"; export default class URLRedirect extends Model { public static get table(): string {