Skip to content

Commit

Permalink
imporving name in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mimiMonads committed Oct 31, 2024
1 parent b65a660 commit b5a48fa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
6 changes: 2 additions & 4 deletions src/morphism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ export const petitions = {
type: 1,
},
}),
/**
*
/**
* Enhances a function with additional typings for handling HTTP requests within the 'vixeny' framework.
* This function binds the provided Morphism to the rules set by `composer`, producing a typed `Petition`.
* The resulting function can be used with `wrap` or can be `composed`, and it's guaranteed to return a `Response` or `Promise<Response>`.
Expand All @@ -118,7 +117,7 @@ export const petitions = {
* });
* ```
*/
add: <
add: <
FC extends CyclePluginMap,
O extends FunRouterOptions<FC>,
>(o?: O) =>
Expand Down Expand Up @@ -155,7 +154,6 @@ export const petitions = {
o,
}) as unknown as Petition,
/**
*
* Enhances a function with additional typings for handling HTTP requests within the 'vixeny' framework.
* This function binds the provided Morphism to the rules set by `composer`, producing a typed `Petition`.
* The resulting function can be used with `wrap` or can be `composed`, and it's guaranteed to return a `Response` or `Promise<Response>`.
Expand Down
22 changes: 10 additions & 12 deletions src/runtime/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@
* This function is useful for applications that need to adapt their behavior based on the runtime environment.
*
* ```js
* import { runtime } from 'vixeny'
*
* //logging runtime name
* console.log(
* runtime.name()
* )
* import runtime from './runtime';
*
* // Logging runtime name
* console.log(runtime());
* ```
*/

//@ts-nocheck
export default () =>
//@ts-ignore
typeof Bun !== "undefined"
typeof globalThis.Bun !== "undefined"
? "Bun"
//@ts-ignore
: typeof Bun !== "undefined"
: typeof globalThis.Deno !== "undefined"
? "Deno"
: "Node";
: typeof process !== "undefined" && typeof process.versions === "object" &&
!!process.versions.node
? "Node"
: "Unknown";
7 changes: 4 additions & 3 deletions src/staticFiles/composedPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default (o?: FunRouterOptions<any>) =>
((checks) =>
checks
? staticFileTools.getValidPetitionFromPlugin(o)(checks)(
root,
)(x)(name)
root,
)(x)(name)
: ({
path: root.slice(1, -1) + x.slice(name.length - 1),
...mimeIsTrue(f)("." + x.split(".").at(-1)),
Expand Down Expand Up @@ -63,7 +63,8 @@ export default (o?: FunRouterOptions<any>) =>
((checks) =>
checks
? staticFileTools.getValidPetitionFromPlugin(o)(checks)(root)(x)(
name)
name,
)
: ({
path: root.slice(1, -1) + x.slice(name.length - 1),
type: "base",
Expand Down
11 changes: 6 additions & 5 deletions test/staticFile/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ test(
template: [plugins.staticFilePlugin({
checker: (s) => s.path.includes(".png"),
type: "add",
p: (options) => petitions.add()({
path: options.relativeName.slice(0, -4),
f:() => new Response('hello')
}),
p: (options) =>
petitions.add()({
path: options.relativeName.slice(0, -4),
f: () => new Response("hello"),
}),
})],
}).some(p => p.path === "/hello/nested/logo"),
}).some((p) => p.path === "/hello/nested/logo"),
true,
),
);

0 comments on commit b5a48fa

Please sign in to comment.