diff --git a/src/app.ts b/src/app.ts index 9e39145..d74458a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,7 +1,7 @@ -import { initDb } from './db'; +import { initDb } from './services/db'; (async () => { await initDb(); - (await import('./worker')).default(); - (await import('./server')).default(); + (await import('./services/worker')).default(); + (await import('./server/server')).default(); })(); \ No newline at end of file diff --git a/src/format.ts b/src/functions/format.ts similarity index 77% rename from src/format.ts rename to src/functions/format.ts index eddd6ac..725c69c 100644 --- a/src/format.ts +++ b/src/functions/format.ts @@ -1,10 +1,10 @@ -import { api } from './misskey'; -import { config } from './config'; -import { User } from './models/entities/user'; +import { api } from '../services/misskey'; +import { config } from '../config'; +import { User } from '../models/entities/user'; import { updateUser } from './users'; export const format = async (user: User): Promise => { - const miUser = await api>(user.host, 'users/show', { username: user.username }, user.token); + const miUser = await api>(user.host, 'users/show', { username: user.username }, user.token); if (miUser.error) { throw miUser.error; } diff --git a/src/users.ts b/src/functions/users.ts similarity index 90% rename from src/users.ts rename to src/functions/users.ts index 16dc7db..0bc8f0b 100644 --- a/src/users.ts +++ b/src/functions/users.ts @@ -1,5 +1,5 @@ -import { User } from './models/entities/user'; -import { Users } from './models'; +import { User } from '../models/entities/user'; +import { Users } from '../models'; import { DeepPartial } from 'typeorm'; export const getUser = (username: string, host: string): Promise => { diff --git a/src/die.ts b/src/server/die.ts similarity index 100% rename from src/die.ts rename to src/server/die.ts diff --git a/src/render.ts b/src/server/render.ts similarity index 78% rename from src/render.ts rename to src/server/render.ts index d385040..90e00a7 100644 --- a/src/render.ts +++ b/src/server/render.ts @@ -1,7 +1,7 @@ import views from 'koa-views'; -import constant from './const'; +import constant from '../const'; export const render = views(__dirname + '/views', { extension: 'pug', options: { diff --git a/src/router.ts b/src/server/router.ts similarity index 98% rename from src/router.ts rename to src/server/router.ts index 38fbe62..a72c3b7 100644 --- a/src/router.ts +++ b/src/server/router.ts @@ -5,9 +5,9 @@ import crypto from 'crypto'; import { die } from './die'; import { v4 as uuid } from 'uuid'; -import { config } from './config'; -import { upsertUser, getUser, getUserCount, updateUser } from './users'; -import { api } from './misskey'; +import { config } from '../config'; +import { upsertUser, getUser, getUserCount, updateUser } from '../functions/users'; +import { api } from '../services/misskey'; export const router = new Router(); diff --git a/src/server.ts b/src/server/server.ts similarity index 89% rename from src/server.ts rename to src/server/server.ts index c3ef7db..f4bd7b0 100644 --- a/src/server.ts +++ b/src/server/server.ts @@ -5,10 +5,10 @@ import bodyParser from 'koa-bodyparser'; import serve from 'koa-static'; import mount from 'koa-mount'; -import constant from './const'; +import constant from '../const'; import { router } from './router'; import { render } from './render'; -import { config } from './config'; +import { config } from '../config'; export default (): void => { const app = new Koa(); diff --git a/src/db.ts b/src/services/db.ts similarity index 87% rename from src/db.ts rename to src/services/db.ts index 52d2ec1..a7e106f 100644 --- a/src/db.ts +++ b/src/services/db.ts @@ -1,6 +1,6 @@ import { getConnection, createConnection, Connection } from 'typeorm'; -import { config } from './config'; -import { User } from './models/entities/user'; +import { config } from '../config'; +import { User } from '../models/entities/user'; export const entities = [ User diff --git a/src/misskey.ts b/src/services/misskey.ts similarity index 94% rename from src/misskey.ts rename to src/services/misskey.ts index 0338c4e..52dbf89 100644 --- a/src/misskey.ts +++ b/src/services/misskey.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import _const from './const'; +import _const from '../const'; export const ua = `Mozilla/5.0 misshaialertBot/${_const.version} +https://github.com/Xeltica/misshaialert Node/${process.version}`; diff --git a/src/worker.ts b/src/services/worker.ts similarity index 87% rename from src/worker.ts rename to src/services/worker.ts index 7659a2b..91bae3d 100644 --- a/src/worker.ts +++ b/src/services/worker.ts @@ -1,10 +1,10 @@ import cron from 'node-cron'; import delay from 'delay'; -import { Users } from './models'; +import { Users } from '../models'; import { api } from './misskey'; -import { format } from './format'; -import { deleteUser } from './users'; +import { format } from '../functions/format'; +import { deleteUser } from '../functions/users'; export default (): void => { cron.schedule('0 0 0 * * *', async () => {