Skip to content

Commit ff721cb

Browse files
author
scinorandex
committed
Organize files
1 parent 96ca817 commit ff721cb

15 files changed

+44
-36
lines changed

src/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import express from "express";
22
import morgan from "morgan";
33
import { errorHandler } from "./api/errorHandler";
44
import { plainRouter } from "./api/plainRouter";
5-
import { router } from "./api/router";
5+
import { regularRouter } from "./api/regularRouter";
66
import { userAgentMiddleware } from "./api/userAgent";
7-
import { lines } from "./utils/getResponses";
7+
import { lines } from "./utils/libs/getResponses";
88

99
const port = parseInt(process.env.PORT!) || 7070;
1010

@@ -19,7 +19,7 @@ app.use(userAgentMiddleware);
1919
app.use(["/quiet/basic", "/quiet/cmd", "/quiet/plain"], plainRouter);
2020
app.use(["/basic", "/cmd", "/plain"], plainRouter);
2121

22-
app.use(["/quiet", "/"], router);
22+
app.use(["/quiet", "/"], regularRouter);
2323
app.use("/", errorHandler);
2424

2525
// Not found handler

src/api/plainRouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
informationPerCountryPlain,
66
historyPerCountryPlain,
77
globalHistoryPlain,
8-
} from "../utils/plainHandlers";
9-
import { isQuiet } from "./router";
8+
} from "../utils/routes/plain/plainHandlers";
9+
import { isQuiet } from "./regularRouter";
1010

1111
/**
1212
* The plainRouter handles all the plain routes such as /basic, /cmd, and /plain
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
globalInformation,
55
historyPerCountry,
66
informationPerCountry,
7-
} from "../utils/handlers";
7+
} from "../utils/routes/regular/regularHandlers";
88
import handleAsync from "./handleAsync";
99

1010
/**
@@ -16,13 +16,12 @@ export const isQuiet: (req: Request) => boolean = (req) =>
1616
req.baseUrl.startsWith("/quiet");
1717

1818
/**
19-
* The rootRouter handles all the processing of the requests *after* passing through
19+
* The regularRouter handles all the processing of the requests *after* passing through
2020
* all middlewares except not found and error handling middleware
2121
*/
22-
export const router = Router({ mergeParams: true });
22+
export const regularRouter = Router({ mergeParams: true });
2323

24-
// rootRouter.get("/history/:country/:type", historyPerCountryAndType);
25-
router.get(
24+
regularRouter.get(
2625
"/history/:mode?",
2726
handleAsync(async (req, res, next) => {
2827
// get mode from params
@@ -37,7 +36,7 @@ router.get(
3736
})
3837
);
3938

40-
router.get(
39+
regularRouter.get(
4140
"/history/:country/:mode?",
4241
handleAsync(async (req, res, next) => {
4342
const country = req.params.country;
@@ -53,15 +52,15 @@ router.get(
5352
})
5453
);
5554

56-
router.get(
55+
regularRouter.get(
5756
"/:country",
5857
handleAsync(async (req, res, _next) => {
5958
const country = req.params.country;
6059
res.send(await informationPerCountry(country, isQuiet(req)));
6160
})
6261
);
6362

64-
router.get(
63+
regularRouter.get(
6564
"/",
6665
handleAsync(async (req, res, _next) => {
6766
res.send(await globalInformation(isQuiet(req)));

src/api/userAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Request, Response, NextFunction } from "express";
2-
import { lines } from "../utils/getResponses";
2+
import { lines } from "../utils/libs/getResponses";
33

44
// Type of middleware and handler
55
export type Handler = (

src/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#!/usr/bin/env node
22
import argv from "minimist";
3-
import { lines, welcomeMessage } from "./utils/getResponses";
3+
import { lines, welcomeMessage } from "./utils/libs/getResponses";
44
import {
55
globalHistory,
66
globalInformation,
77
historyPerCountry,
88
informationPerCountry,
9-
} from "./utils/handlers";
9+
} from "./utils/routes/regular/regularHandlers";
1010
import {
1111
globalHistoryPlain,
1212
globalInformationPlain,
1313
historyPerCountryPlain,
1414
informationPerCountryPlain,
15-
} from "./utils/plainHandlers";
15+
} from "./utils/routes/plain/plainHandlers";
1616

1717
const args = argv(process.argv.slice(2));
1818
let { history, mode, help, quiet, plain } = args;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { version } = require("../../package.json");
1+
const { version } = require("../../../package.json");
22

33
// This file is a centralized location to get responses to the user
44
// Such as the BMC link, the twitter link, github repo page etc.

0 commit comments

Comments
 (0)