From 18cd2c7b1f325f2d2399092b1e87300084ebeaf0 Mon Sep 17 00:00:00 2001 From: Kaede Fujisaki Date: Fri, 23 Jul 2021 21:13:18 +0900 Subject: [PATCH] organize imports --- server/src/controller/both/EntityController.ts | 3 ++- server/src/controller/both/MomentBodyController.ts | 2 +- server/src/controller/omote/IndexController.ts | 1 + server/src/controller/omote/MomentController.ts | 2 ++ server/src/controller/omote/RandomSelectionController.ts | 2 +- server/src/controller/ura/DeleteController.ts | 1 - server/src/controller/ura/EditController.ts | 2 ++ server/src/controller/ura/IndexController.ts | 3 ++- server/src/controller/ura/MomentListController.ts | 4 +++- server/src/controller/ura/NewController.ts | 2 ++ server/src/controller/ura/UploadController.ts | 3 ++- server/src/controller/ura/lib/EditorTemplate.ts | 3 ++- server/src/controller/ura/lib/UraTemplate.ts | 4 +++- server/src/main.ts | 1 + server/src/repo/Pool.ts | 4 ++-- server/src/repo/Repo.ts | 9 +++++---- server/src/shelf/Shelf.ts | 4 +++- server/src/storage/Storage.ts | 3 ++- 18 files changed, 36 insertions(+), 17 deletions(-) diff --git a/server/src/controller/both/EntityController.ts b/server/src/controller/both/EntityController.ts index 2aa9015..78ed797 100644 --- a/server/src/controller/both/EntityController.ts +++ b/server/src/controller/both/EntityController.ts @@ -1,6 +1,7 @@ -import Shelf from '../../shelf/Shelf'; import {FastifyReply, FastifyRequest, RequestGenericInterface} from 'fastify'; +import Shelf from '../../shelf/Shelf'; + export interface EntityControllerInterface extends RequestGenericInterface { Params: { id: string, diff --git a/server/src/controller/both/MomentBodyController.ts b/server/src/controller/both/MomentBodyController.ts index 770a7eb..c76355e 100644 --- a/server/src/controller/both/MomentBodyController.ts +++ b/server/src/controller/both/MomentBodyController.ts @@ -2,7 +2,7 @@ import {FastifyReply, FastifyRequest} from 'fastify'; import MomentRenderer from '../../renderer/MomentRenderer'; import Shelf from '../../shelf/Shelf'; import {parseMomentPath} from '../../shelf/Moment'; -import dayjs from "dayjs"; +import dayjs from 'dayjs'; export default class MomentBodyController { private readonly shelf: Shelf; diff --git a/server/src/controller/omote/IndexController.ts b/server/src/controller/omote/IndexController.ts index 7390a05..8f1685b 100644 --- a/server/src/controller/omote/IndexController.ts +++ b/server/src/controller/omote/IndexController.ts @@ -1,5 +1,6 @@ import {FastifyReply, FastifyRequest} from 'fastify'; import Handlebars from 'handlebars'; + import Asset from 'lib/asset'; export default class IndexController { diff --git a/server/src/controller/omote/MomentController.ts b/server/src/controller/omote/MomentController.ts index 7bbedd1..6a762ed 100644 --- a/server/src/controller/omote/MomentController.ts +++ b/server/src/controller/omote/MomentController.ts @@ -1,6 +1,8 @@ import Handlebars from 'handlebars'; import {FastifyReply, FastifyRequest} from 'fastify'; + import Asset from 'lib/asset'; + import Shelf from '../../shelf/Shelf'; import { parseMomentPath } from '../../shelf/Moment'; diff --git a/server/src/controller/omote/RandomSelectionController.ts b/server/src/controller/omote/RandomSelectionController.ts index 95a5bea..2e4f572 100644 --- a/server/src/controller/omote/RandomSelectionController.ts +++ b/server/src/controller/omote/RandomSelectionController.ts @@ -1,10 +1,10 @@ import {FastifyReply, FastifyRequest, RequestGenericInterface} from 'fastify'; +import dayjs from 'dayjs'; import * as protocol from 'lib/protocol'; import Shelf from '../../shelf/Shelf'; import {formatMomentPath, formatMomentTime, MomentSummary} from '../../shelf/Moment'; -import dayjs from "dayjs"; export interface RandomSelectionControllerInterface extends RequestGenericInterface { Querystring: { diff --git a/server/src/controller/ura/DeleteController.ts b/server/src/controller/ura/DeleteController.ts index 0b8fea9..bdacaaf 100644 --- a/server/src/controller/ura/DeleteController.ts +++ b/server/src/controller/ura/DeleteController.ts @@ -1,4 +1,3 @@ -import dayjs from 'dayjs'; import { FastifyReply, FastifyRequest } from 'fastify'; import * as protocol from 'lib/protocol'; diff --git a/server/src/controller/ura/EditController.ts b/server/src/controller/ura/EditController.ts index 1488860..c2bbe08 100644 --- a/server/src/controller/ura/EditController.ts +++ b/server/src/controller/ura/EditController.ts @@ -1,5 +1,7 @@ import {FastifyReply, FastifyRequest} from 'fastify'; + import Asset from 'lib/asset'; + import EditorTemplate from './lib/EditorTemplate'; import Shelf from '../../shelf/Shelf'; import {parseMomentPath, formatMomentTime} from '../../shelf/Moment'; diff --git a/server/src/controller/ura/IndexController.ts b/server/src/controller/ura/IndexController.ts index 39b5111..1ff12f1 100644 --- a/server/src/controller/ura/IndexController.ts +++ b/server/src/controller/ura/IndexController.ts @@ -1,6 +1,7 @@ import {FastifyReply, FastifyRequest} from 'fastify'; -import Handlebars from 'handlebars'; + import Asset from 'lib/asset'; + import UraTemplate from './lib/UraTemplate'; export default class IndexController { diff --git a/server/src/controller/ura/MomentListController.ts b/server/src/controller/ura/MomentListController.ts index 724845a..7f2f9aa 100644 --- a/server/src/controller/ura/MomentListController.ts +++ b/server/src/controller/ura/MomentListController.ts @@ -1,8 +1,10 @@ import {FastifyReply, FastifyRequest, RequestGenericInterface} from 'fastify'; +import dayjs from 'dayjs'; + import Asset from 'lib/asset'; + import UraTemplate from './lib/UraTemplate'; import Shelf from '../../shelf/Shelf'; -import dayjs from "dayjs"; import {formatMomentPath} from '../../shelf/Moment'; export interface MomentListControllerInterface extends RequestGenericInterface { diff --git a/server/src/controller/ura/NewController.ts b/server/src/controller/ura/NewController.ts index a36f75b..8da9bc0 100644 --- a/server/src/controller/ura/NewController.ts +++ b/server/src/controller/ura/NewController.ts @@ -1,5 +1,7 @@ import {FastifyReply, FastifyRequest} from 'fastify'; + import Asset from 'lib/asset'; + import EditorTemplate from './lib/EditorTemplate'; export default class NewController { diff --git a/server/src/controller/ura/UploadController.ts b/server/src/controller/ura/UploadController.ts index d178608..e9306e2 100644 --- a/server/src/controller/ura/UploadController.ts +++ b/server/src/controller/ura/UploadController.ts @@ -1,6 +1,7 @@ -import Shelf from '../../shelf/Shelf'; import {FastifyReply, FastifyRequest} from 'fastify'; +import Shelf from '../../shelf/Shelf'; + export default class UploadController { private readonly shelf: Shelf; constructor(shelf: Shelf) { diff --git a/server/src/controller/ura/lib/EditorTemplate.ts b/server/src/controller/ura/lib/EditorTemplate.ts index fa60973..6ddd169 100644 --- a/server/src/controller/ura/lib/EditorTemplate.ts +++ b/server/src/controller/ura/lib/EditorTemplate.ts @@ -1,6 +1,7 @@ -import UraTemplate from './UraTemplate'; import Asset from 'lib/asset'; +import UraTemplate from './UraTemplate'; + type EditorData = { title: string; author: string; diff --git a/server/src/controller/ura/lib/UraTemplate.ts b/server/src/controller/ura/lib/UraTemplate.ts index af53848..182c657 100644 --- a/server/src/controller/ura/lib/UraTemplate.ts +++ b/server/src/controller/ura/lib/UraTemplate.ts @@ -1,7 +1,9 @@ import Handlebars, {Template} from 'handlebars'; +import dayjs from 'dayjs'; + import Asset from 'lib/asset'; + import Config from '../../../Config'; -import dayjs from "dayjs"; const kCompileOption: CompileOptions = { preventIndent: true, diff --git a/server/src/main.ts b/server/src/main.ts index a341aa8..244b87d 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -1,4 +1,5 @@ import Asset from 'lib/asset'; + import Server from './Server'; import Shelf from './shelf/Shelf'; import Repo from './repo/Repo'; diff --git a/server/src/repo/Pool.ts b/server/src/repo/Pool.ts index 1bb7631..9ad2a1f 100644 --- a/server/src/repo/Pool.ts +++ b/server/src/repo/Pool.ts @@ -1,6 +1,6 @@ import * as genericPool from 'generic-pool'; -import {Client, Result, ResultIterator} from 'ts-postgres'; -import {Value} from 'ts-postgres/src/types'; +import { Client, ResultIterator } from 'ts-postgres'; +import { Value } from 'ts-postgres/src/types'; export default class Pool { private pool: genericPool.Pool diff --git a/server/src/repo/Repo.ts b/server/src/repo/Repo.ts index ca58664..85a2203 100644 --- a/server/src/repo/Repo.ts +++ b/server/src/repo/Repo.ts @@ -1,10 +1,11 @@ -import Pool from './Pool'; -import {Entity} from '../shelf/Entity'; import dayjs from 'dayjs'; +import NodeCache from 'node-cache'; +import { ResultRow } from 'ts-postgres'; + +import Pool from './Pool'; +import { Entity } from '../shelf/Entity'; import Config from '../Config'; import { Moment, MomentSummary } from '../shelf/Moment'; -import NodeCache from 'node-cache'; -import {ResultRow} from "ts-postgres"; export default class Repo { private readonly pool: Pool; diff --git a/server/src/shelf/Shelf.ts b/server/src/shelf/Shelf.ts index 9fe413c..ae8efed 100644 --- a/server/src/shelf/Shelf.ts +++ b/server/src/shelf/Shelf.ts @@ -1,15 +1,17 @@ import path from 'path'; import * as os from 'os'; import * as fs from 'fs/promises'; +import dayjs from 'dayjs'; + import * as protocol from 'lib/protocol'; import * as fml from 'lib/fml'; import { probe } from 'lib/media/probe'; import { resizeImage, makeImageIcon, makeVideoIcon, makeAudioIcon } from 'lib/media/convert'; + import Repo from '../repo/Repo'; import Storage from '../storage/Storage'; import { Entity, ImageEntity, VideoEntity, AudioEntity } from './Entity'; import {Moment, MomentSummary, formatMomentTime, parseMomentTime} from './Moment'; -import dayjs from "dayjs"; class Shelf { readonly storagePath: string; diff --git a/server/src/storage/Storage.ts b/server/src/storage/Storage.ts index 36c16c0..f418cf6 100644 --- a/server/src/storage/Storage.ts +++ b/server/src/storage/Storage.ts @@ -1,7 +1,8 @@ import path from 'path'; -import md5sum from 'lib/md5sum'; import * as fs from 'fs/promises'; +import md5sum from 'lib/md5sum'; + function storedPathOf(hash: string): string { const dir01 = hash.slice(0,2); const dir02 = hash.slice(2,4);