Skip to content

Commit

Permalink
examples: add ts path alias and rollup typescript plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jaipaljadeja committed Dec 9, 2024
1 parent 534a10a commit 029c9df
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 40 deletions.
7 changes: 4 additions & 3 deletions examples/cli/apibara.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import typescript from "@rollup/plugin-typescript";
import { defineConfig } from "apibara/config";

export default defineConfig({
Expand All @@ -11,7 +12,7 @@ export default defineConfig({
},
},
},
// rollupConfig: {
// plugins: [tsConfigPaths()],
// },
rollupConfig: {
plugins: [typescript()],
},
});
4 changes: 2 additions & 2 deletions examples/cli/indexers/1-evm.indexer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { db } from "@/lib/db";
import { ethereumUsdcTransfers } from "@/lib/schema";
import { EvmStream } from "@apibara/evm";
import { defineIndexer, useSink } from "@apibara/indexer";
import { drizzlePersistence } from "@apibara/indexer/plugins/drizzle-persistence";
Expand All @@ -10,8 +12,6 @@ import type {
} from "drizzle-orm";
import type { PgDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
import { encodeEventTopics, parseAbi } from "viem";
import { db } from "../lib/db";
import { ethereumUsdcTransfers } from "../lib/schema";

const abi = parseAbi([
"event Transfer(address indexed from, address indexed to, uint256 value)",
Expand Down
4 changes: 2 additions & 2 deletions examples/cli/indexers/2-starknet.indexer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { db } from "@/lib/db";
import { starknetUsdcTransfers } from "@/lib/schema";
import { defineIndexer, useSink } from "@apibara/indexer";
import { drizzlePersistence } from "@apibara/indexer/plugins/drizzle-persistence";
import { useLogger } from "@apibara/indexer/plugins/logger";
Expand All @@ -10,8 +12,6 @@ import type {
} from "drizzle-orm";
import type { PgDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
import { hash } from "starknet";
import { db } from "../lib/db";
import { starknetUsdcTransfers } from "../lib/schema";

// USDC Transfers on Starknet
export default function (runtimeConfig: ApibaraRuntimeConfig) {
Expand Down
3 changes: 2 additions & 1 deletion examples/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.5.2",
"@types/pg": "^8.11.10",
"drizzle-kit": "^0.29.0",
"rollup-plugin-tsconfig-paths": "^1.5.2",
"typescript": "^5.6.2",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^1.6.0"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions examples/cli/test/ethereum.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createIndexer } from "@/indexers/1-evm.indexer";
import { ethereumUsdcTransfers } from "@/lib/schema";
import * as schema from "@/lib/schema";
import { createVcr } from "@apibara/indexer/testing";
import { drizzle } from "drizzle-orm/pglite";
import { beforeAll, describe, expect, it } from "vitest";
import { createIndexer } from "../indexers/1-evm.indexer";
import { ethereumUsdcTransfers } from "../lib/schema";
import * as schema from "../lib/schema";
import { migratePglite } from "./helper";

const vcr = createVcr();
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/test/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as schema from "@/lib/schema";
import type { PgliteDatabase } from "drizzle-orm/pglite";
import { migrate } from "drizzle-orm/pglite/migrator";
import type * as schema from "../lib/schema";

export async function migratePglite(database: PgliteDatabase<typeof schema>) {
return await migrate(database, { migrationsFolder: "./drizzle" });
Expand Down
6 changes: 3 additions & 3 deletions examples/cli/test/starknet.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createIndexer } from "@/indexers/2-starknet.indexer";
import { starknetUsdcTransfers } from "@/lib/schema";
import * as schema from "@/lib/schema";
import { createVcr } from "@apibara/indexer/testing";
import { drizzle } from "drizzle-orm/pglite";
import { beforeAll, describe, expect, it } from "vitest";
import { createIndexer } from "../indexers/2-starknet.indexer";
import { starknetUsdcTransfers } from "../lib/schema";
import * as schema from "../lib/schema";
import { migratePglite } from "./helper";

const vcr = createVcr();
Expand Down
6 changes: 5 additions & 1 deletion examples/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"skipLibCheck": true,
"types": ["node"],
"noEmit": true,
"strict": true
"strict": true,
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
},
"include": [".", "./.apibara/types"],
"exclude": ["node_modules"]
Expand Down
2 changes: 2 additions & 0 deletions examples/cli/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import tsconfigPaths from "vite-tsconfig-paths";
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
testTimeout: 10000,
},
plugins: [tsconfigPaths()],
});
68 changes: 44 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 029c9df

Please sign in to comment.