Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed Apr 7, 2023
1 parent 20ddedd commit f4a8348
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions capn/syncConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { startNetwork } from "./startNetwork.ts"
export async function syncConfig(tempDir: string, config: CapiConfig) {
return withSignal(async (signal) => {
const { server } = config
let entries = new Map<string, CodegenEntry>()
const entries = new Map<string, CodegenEntry>()
await Promise.all(
Object.entries(config.chains ?? {}).map(async ([name, chain]) => {
if (chain.url != null) {
Expand Down Expand Up @@ -54,10 +54,10 @@ export async function syncConfig(tempDir: string, config: CapiConfig) {
)
}),
)
entries = new Map([...entries].sort((a, b) => a[0] < b[0] ? 1 : -1))
const sortedEntries = new Map([...entries].sort((a, b) => a[0] < b[0] ? 1 : -1))
const codegenHash = await uploadCodegenSpec(server, {
type: "v0",
codegen: entries,
codegen: sortedEntries,
})
return new URL(codegenHash + "/", server).toString()
})
Expand Down
4 changes: 2 additions & 2 deletions cli/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as flags from "../deps/std/flags.ts"
import * as path from "../deps/std/path.ts"

export async function resolveConfig(...args: string[]) {
const { config: configFile } = flags.parse(args, {
const { config: rawConfigPath } = flags.parse(args, {
string: ["config"],
default: {
config: "./capi.config.ts",
},
})
const configPath = path.resolve(configFile)
const configPath = path.resolve(rawConfigPath)
await Deno.stat(configPath)
const configModule = await import(path.toFileUrl(configPath).toString())
const config = configModule.config
Expand Down
15 changes: 10 additions & 5 deletions cli/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createTempDir } from "../capn/createTempDir.ts"
import { createCapnHandler } from "../capn/mod.ts"
import * as flags from "../deps/std/flags.ts"
import { serve } from "../deps/std/http.ts"
import { createCorsHandler } from "../server/corsHandler.ts"
import { createErrorHandler } from "../server/errorHandler.ts"
import { createCodegenHandler } from "../server/mod.ts"
import { InMemoryCache } from "../util/cache/memory.ts"
Expand Down Expand Up @@ -38,12 +39,16 @@ export default async function(...args: string[]) {
if (!running) {
const capnHandler = createCapnHandler(tempDir, config, signal)
const codegenHandler = createCodegenHandler(dataCache, tempCache)
const handler = createErrorHandler((request) => {
if (new URL(request.url).pathname.startsWith("/capn/")) {
return capnHandler(request)
const handler = createCorsHandler(createErrorHandler(async (request) => {
const { pathname } = new URL(request.url)
if (pathname === "/capi_cwd") {
return new Response(Deno.cwd())
}
return codegenHandler(request)
})
if (pathname.startsWith("/capn/")) {
return await capnHandler(request)
}
return await codegenHandler(request)
}))
await serve(handler, {
hostname: "[::]",
port: +port,
Expand Down
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * as $ from "./deps/scale.ts"
export { BitSequence } from "./deps/scale.ts"

// moderate --exclude main.ts providers server util
// moderate --exclude main.ts server util capi.config.ts

export * from "./capi.config.ts"
export * from "./capn/mod.ts"
Expand Down
5 changes: 0 additions & 5 deletions rpc/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import { RpcCallMessage, RpcIngressMessage, RpcSubscriptionHandler } from "./rpc

const connectionMemos = new Map<new(discovery: any) => Connection, Map<unknown, Connection>>()

export interface ConnectionCtorLike<D> {
new(discovery: D): Connection
connect: (discovery: D, signal: AbortSignal) => Connection
}

export abstract class Connection {
nextId = 0
references = 0
Expand Down

0 comments on commit f4a8348

Please sign in to comment.