Skip to content

Commit 88b988c

Browse files
authored
refactor: Simplify folder organization in the repo (#796)
* Revert "Revert "refactor: clearer folder organization (#792)" (#795)" This reverts commit 8f668fe. * copy scripts folder * move scripts back * fix import
1 parent d3d9a2a commit 88b988c

File tree

445 files changed

+979
-1005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

445 files changed

+979
-1005
lines changed

.vscode/settings.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import "./polyfill";
2+
import "./tracer";
3+
24
import { initServer } from "./server";
3-
import { env } from "./utils/env";
4-
import { logger } from "./utils/logger";
5-
import "./utils/tracer";
5+
import { env } from "./shared/utils/env";
6+
import { logger } from "./shared/utils/logger";
67
import { initWorker } from "./worker";
78
import { CancelRecycledNoncesQueue } from "./worker/queues/cancelRecycledNoncesQueue";
89
import { MineTransactionQueue } from "./worker/queues/mineTransactionQueue";

src/polyfill.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as crypto from "crypto";
1+
import * as crypto from "node:crypto";
22

33
if (typeof globalThis.crypto === "undefined") {
44
(globalThis as any).crypto = crypto;

src/scripts/apply-migrations.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { logger } from "../utils/logger";
2-
import { acquireLock, releaseLock, waitForLock } from "../utils/redis/lock";
3-
import { redis } from "../utils/redis/redis";
1+
import { logger } from "../shared/utils/logger";
2+
import {
3+
acquireLock,
4+
releaseLock,
5+
waitForLock,
6+
} from "../shared/utils/redis/lock";
7+
import { redis } from "../shared/utils/redis/redis";
48

59
const MIGRATION_LOCK_TTL_SECONDS = 60;
610

src/scripts/setup-db.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { execSync } from "child_process";
2-
import { prisma } from "../db/client";
1+
import { execSync } from "node:child_process";
2+
import { prisma } from "../shared/db/client";
33

44
const main = async () => {
55
const [{ exists: hasWalletsTable }]: [{ exists: boolean }] =
@@ -14,8 +14,8 @@ const main = async () => {
1414

1515
const schema =
1616
process.env.NODE_ENV === "production"
17-
? `./dist/prisma/schema.prisma`
18-
: `./src/prisma/schema.prisma`;
17+
? "./dist/prisma/schema.prisma"
18+
: "./src/prisma/schema.prisma";
1919

2020
if (hasWalletsTable) {
2121
execSync(`yarn prisma migrate reset --force --schema ${schema}`, {

src/server/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import fastify, { type FastifyInstance } from "fastify";
33
import * as fs from "node:fs";
44
import path from "node:path";
55
import { URL } from "node:url";
6-
import { clearCacheCron } from "../utils/cron/clearCacheCron";
7-
import { env } from "../utils/env";
8-
import { logger } from "../utils/logger";
9-
import { metricsServer } from "../utils/prometheus";
10-
import { withServerUsageReporting } from "../utils/usage";
6+
import { clearCacheCron } from "../shared/utils/cron/clearCacheCron";
7+
import { env } from "../shared/utils/env";
8+
import { logger } from "../shared/utils/logger";
9+
import { metricsServer } from "../shared/utils/prometheus";
10+
import { withServerUsageReporting } from "../shared/utils/usage";
1111
import { updateTxListener } from "./listeners/updateTxListener";
1212
import { withAdminRoutes } from "./middleware/adminRoutes";
1313
import { withAuth } from "./middleware/auth";

src/server/listeners/updateTxListener.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { knex } from "../../db/client";
2-
import { TransactionDB } from "../../db/transactions/db";
3-
import { logger } from "../../utils/logger";
1+
import { knex } from "../../shared/db/client";
2+
import { TransactionDB } from "../../shared/db/transactions/db";
3+
import { logger } from "../../shared/utils/logger";
44
import { toTransactionSchema } from "../schemas/transaction";
55
import { subscriptionsData } from "../schemas/websocket";
66
import {

src/server/middleware/adminRoutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Queue } from "bullmq";
55
import type { FastifyInstance } from "fastify";
66
import { StatusCodes } from "http-status-codes";
77
import { timingSafeEqual } from "node:crypto";
8-
import { env } from "../../utils/env";
8+
import { env } from "../../shared/utils/env";
99
import { CancelRecycledNoncesQueue } from "../../worker/queues/cancelRecycledNoncesQueue";
1010
import { MineTransactionQueue } from "../../worker/queues/mineTransactionQueue";
1111
import { NonceHealthCheckQueue } from "../../worker/queues/nonceHealthCheckQueue";

src/server/middleware/auth.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ import {
55
type ThirdwebAuthUser,
66
} from "@thirdweb-dev/auth/fastify";
77
import { AsyncWallet } from "@thirdweb-dev/wallets/evm/wallets/async";
8-
import { createHash } from "crypto";
8+
import { createHash } from "node:crypto";
99
import type { FastifyInstance } from "fastify";
1010
import type { FastifyRequest } from "fastify/types/request";
1111
import jsonwebtoken, { type JwtPayload } from "jsonwebtoken";
1212
import { validate as uuidValidate } from "uuid";
13-
import { getPermissions } from "../../db/permissions/getPermissions";
14-
import { createToken } from "../../db/tokens/createToken";
15-
import { revokeToken } from "../../db/tokens/revokeToken";
16-
import { WebhooksEventTypes } from "../../schema/webhooks";
17-
import { THIRDWEB_DASHBOARD_ISSUER, handleSiwe } from "../../utils/auth";
18-
import { getAccessToken } from "../../utils/cache/accessToken";
19-
import { getAuthWallet } from "../../utils/cache/authWallet";
20-
import { getConfig } from "../../utils/cache/getConfig";
21-
import { getWebhooksByEventType } from "../../utils/cache/getWebhook";
22-
import { getKeypair } from "../../utils/cache/keypair";
23-
import { env } from "../../utils/env";
24-
import { logger } from "../../utils/logger";
25-
import { sendWebhookRequest } from "../../utils/webhook";
26-
import { Permission } from "../schemas/auth";
13+
import { getPermissions } from "../../shared/db/permissions/getPermissions";
14+
import { createToken } from "../../shared/db/tokens/createToken";
15+
import { revokeToken } from "../../shared/db/tokens/revokeToken";
16+
import { WebhooksEventTypes } from "../../shared/schemas/webhooks";
17+
import { THIRDWEB_DASHBOARD_ISSUER, handleSiwe } from "../../shared/utils/auth";
18+
import { getAccessToken } from "../../shared/utils/cache/accessToken";
19+
import { getAuthWallet } from "../../shared/utils/cache/authWallet";
20+
import { getConfig } from "../../shared/utils/cache/getConfig";
21+
import { getWebhooksByEventType } from "../../shared/utils/cache/getWebhook";
22+
import { getKeypair } from "../../shared/utils/cache/keypair";
23+
import { env } from "../../shared/utils/env";
24+
import { logger } from "../../shared/utils/logger";
25+
import { sendWebhookRequest } from "../../shared/utils/webhook";
26+
import { Permission } from "../../shared/schemas/auth";
2727
import { ADMIN_QUEUES_BASEPATH } from "./adminRoutes";
2828
import { OPENAPI_ROUTES } from "./openApi";
2929

src/server/middleware/cors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FastifyInstance } from "fastify";
2-
import { getConfig } from "../../utils/cache/getConfig";
2+
import { getConfig } from "../../shared/utils/cache/getConfig";
33
import { ADMIN_QUEUES_BASEPATH } from "./adminRoutes";
44

55
const STANDARD_METHODS = "GET,POST,DELETE,PUT,PATCH,HEAD,PUT,PATCH,POST,DELETE";

0 commit comments

Comments
 (0)