Skip to content

Commit

Permalink
pushing broken pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
mimiMonads committed Oct 30, 2024
1 parent 3d12ddf commit 7b84eef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/components/nativePlugins/session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as plugins from "../../exportable/plugin.ts";
import { f as cookieParser } from "../cookies/mainCookies.ts";
import type { Petition } from "../../morphism.ts";
import type { CyclePlugin } from "../../options.ts";


interface InnerElement {
lastUsed: {
Expand Down Expand Up @@ -124,7 +124,7 @@ const session = <
tolerance?: number;
autoDeleteTolerance?: number;
injectMap?: Map<string, R>;
}): CyclePlugin<{ isFunction: false; return: SessionType<T> }> => {
}) => {
// Declaring map
const sym = Symbol("session");
const map = opt?.injectMap ?? new Map<string, R>();
Expand All @@ -148,7 +148,7 @@ const session = <
f: (ctx) => {
return mapper<T, R>(map)()(opt?.tolerance ?? 300000)(ctx.getPetition());
},
}) as unknown as CyclePlugin<{ isFunction: false; return: SessionType<T> }>;
});
};

export { session };
1 change: 0 additions & 1 deletion src/exportable/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
} from "../morphism.ts";
import checkerTools from "../composer/checkPetition/checkTools.ts";
import {
type CyclePlugin,
type FunRouterOptions,
globalOptions,
} from "../options.ts";
Expand Down
42 changes: 17 additions & 25 deletions src/morphism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1113,32 +1113,24 @@ export type CryptoOptions = {
};
} | {};

export type StaticFilePlugin<
TP extends "response" | "request" | undefined,
> = {
checker: (path: string) => boolean;
type?: TP;
type StaticFileOptions = {
path: () => string
thisOptions: () => fileServerPetition<any>
globalOptions: () => FunRouterOptions<any>
}
type StaticFilePlugin <> = {
type?: 'add'
async?: boolean;
} & StaticFilePluginExtensions<TP>;
checker?: (ctx: StaticFileOptions) => boolean;
f: (options: {
root: string;
path: string;
o?: FunRouterOptions<any>;
relativeName: string;
}) => (req: Request) => Response
}


export type StaticFilePluginExtensions<
TP extends "response" | "request" | undefined,
> = TP extends "request" ? {
f: (options: {
root: string;
path: string;
o?: FunRouterOptions<any>;
relativeName: string;
}) => ReturnType<ReturnType<typeof petitions.custom>>;
}
: {
r: (options: {
root: string;
path: string;
o?: FunRouterOptions<any>;
relativeName: string;
}) => ReturnType<ReturnType<typeof petitions.response>>;
};

/**
* Object for raw response static.
Expand All @@ -1151,7 +1143,7 @@ export type fileServerPetition<
path: string;
mime?: MI;
extra?: MI extends true ? [string, string][] : never;
template?: StaticFilePlugin<any>[];
template?: StaticFilePlugin[];
removeExtensionOf?: defaultMime[];
slashIs?: string;
};
Expand Down
15 changes: 7 additions & 8 deletions test/staticFile/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { assertEquals } from "@std/assert";
import { test } from "@cross/test";
import main from "../../src/staticFiles/staticFileMain.ts";
import { type fileServerPetition, petitions } from "../../src/morphism.ts";
import { type fileServerPetition } from "../../src/morphism.ts";


test(
"static file checking logo",
Expand Down Expand Up @@ -68,13 +69,11 @@ test(
name: "/hello/nested",
mime: false,
template: [{
checker: (s) => s.includes(".png"),
type: "response",
r: (options) =>
petitions.response()({
path: options.relativeName.slice(0, -4),
r: () => new Response(""),
}),
checker: (s) => s.path().includes(".png"),

Check failure on line 72 in test/staticFile/main.test.ts

View workflow job for this annotation

GitHub Actions / test

TypeError: s.path is not a function. (In 's.path()'

at checker (/home/runner/work/vixeny/vixeny/test/staticFile/main.test.ts:72:29) at find (1:11) at /home/runner/work/vixeny/vixeny/src/staticFiles/composedPaths.ts:77:25 at map (1:11) at /home/runner/work/vixeny/vixeny/src/staticFiles/staticFileMain.ts:14:5 at /home/runner/work/vixeny/vixeny/test/staticFile/main.test.ts:66:14 at /home/runner/work/vixeny/vixeny/node_modules/@cross/test/shims/bun.js:7:23 at new Promise (1:11) at /home/runner/work/vixeny/vixeny/node_modules/@cross/test/shims/bun.js:6:29 at /home/runner/work/vixeny/vixeny/node_modules/@cross/test/shims/bun.js:3:27

Check failure on line 72 in test/staticFile/main.test.ts

View workflow job for this annotation

GitHub Actions / test

TypeError: s.path is not a function. (In 's.path()'

at checker (/home/runner/work/vixeny/vixeny/test/staticFile/main.test.ts:72:29) at find (1:11) at /home/runner/work/vixeny/vixeny/src/staticFiles/composedPaths.ts:77:25 at map (1:11) at /home/runner/work/vixeny/vixeny/src/staticFiles/staticFileMain.ts:14:5 at /home/runner/work/vixeny/vixeny/test/staticFile/main.test.ts:66:14 at /home/runner/work/vixeny/vixeny/node_modules/@cross/test/shims/bun.js:7:23 at new Promise (1:11) at /home/runner/work/vixeny/vixeny/node_modules/@cross/test/shims/bun.js:6:29 at /home/runner/work/vixeny/vixeny/node_modules/@cross/test/shims/bun.js:3:27
type: 'add',
f: (options) =>
() => new Response(options.relativeName.slice(0, -4)),

}],
} as fileServerPetition<false>)
.some((x) => x.path === "/hello/nested/logo"),
Expand Down

0 comments on commit 7b84eef

Please sign in to comment.