swaf upgrade: fix eslint

This commit is contained in:
Alice Gaudon 2022-02-19 09:30:51 +01:00
parent 377c073cd2
commit 5571737d93
9 changed files with 34 additions and 23 deletions

View File

@ -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<string> {
let i = 0;

View File

@ -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 {

View File

@ -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<void> {
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);
}

View File

@ -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<void> {

View File

@ -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<void> {

View File

@ -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<void> {

View File

@ -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<void> {

View File

@ -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<User> {
public id?: number = undefined;

View File

@ -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 {