Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mimi #11

Merged
merged 28 commits into from
May 31, 2024
Merged

Mimi #11

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b474e43
rebasing and adding new type for globalOptions
mimiMonads May 26, 2024
1e6de62
adddpating router to the new types
mimiMonads May 26, 2024
83b6dc5
new monodic structure wrap
mimiMonads May 26, 2024
b5a50bb
moving wrap tp exportable
mimiMonads May 27, 2024
b815eba
adding wrap to elements
mimiMonads May 27, 2024
1ffb8b5
changing types of `response` type
mimiMonads May 27, 2024
1d0f6a2
updating pluging
mimiMonads May 27, 2024
53bb53d
fmt
mimiMonads May 27, 2024
a4ed70a
main complete
mimiMonads May 27, 2024
82f47c1
resolving conflic with options and inference in `petition`
mimiMonads May 28, 2024
38f5b05
testing wrap monoidal properties
mimiMonads May 28, 2024
21186cc
solving issue with `Promise.resolve`
mimiMonads May 28, 2024
e002ede
fixing global options yay!
mimiMonads May 28, 2024
9f32504
type infrence in `fun.ts`
mimiMonads May 29, 2024
510f636
adding `response` to wrap
mimiMonads May 29, 2024
ffa6cf8
adding `compose` to wrap
mimiMonads May 29, 2024
f5eb433
testing petitions
mimiMonads May 29, 2024
fb73e75
deprecating hasName in global options
mimiMonads May 30, 2024
904bf9b
adding `indexBase` with `bind`, which remplaces `hasName`
mimiMonads May 30, 2024
839ad81
updating readme
mimiMonads May 30, 2024
e3310ac
small optimization in method
mimiMonads May 30, 2024
d6c4b1b
jsdocs plugin
mimiMonads May 30, 2024
b279cb2
JSDocs for Petitions
mimiMonads May 30, 2024
259149b
deprecated `date` , `hash`, `randomNumber`
mimiMonads May 30, 2024
79d361a
JSDocs for petition
mimiMonads May 31, 2024
ce8bc80
JSDocs for Morphism in CTX
mimiMonads May 31, 2024
a4ff556
beta ready
mimiMonads May 31, 2024
41895e4
fmt
mimiMonads May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ hi.ts

package-lock.json

deno.lock

8 changes: 3 additions & 5 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
**Welcome to Vixeny: Revolutionize Your Web Development**

`Status : Currently restructuring the project for the beta`

<p align="center">
<img src="misc/logo.png" alt="Vixeny Logo" style="max-width: 100%;">
<br>
Expand All @@ -10,6 +8,8 @@
<code>npx create-vixeny</code> | <code>bun create vixeny</code>
</p>

`Status : Currently restructuring the project for the beta!`

**Vixeny: Pioneering Functional Web Development**

Vixeny is not just another framework; it's a comprehensive solution designed for
Expand Down Expand Up @@ -39,11 +39,9 @@ workflow efficiency.
- **Ironclad Security**: Designed with security at its heart, Vixeny ensures
your applications are safe and sound.
- **Sophisticated Type Checking**: Advanced type system integration for
bulletproof code reliability.
bulletproof code reliability emd-to-end.
- **Harmony of Paradigms**: While rooted in functional programming, Vixeny
gracefully supports a spectrum of programming paradigms.
- **Object-Oriented Features**: Offers the flexibility of object-oriented
principles for straightforward code management.
- **Seamless Testing**: Built from the ground up to accommodate easy and
comprehensive testing strategies.
- **Future-Ready**: Stay at the forefront of web development with cutting-edge
Expand Down
29 changes: 11 additions & 18 deletions fun.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
/*
* Antony @mimiMonads
*
* Vixeny
*
* All programming paradigms have strengths and weaknesses and while this middleware is functional,
* it does not mean that it is better than other paradigms.
*
* I highly recommend that you do not proceed unless you have a solid foundation in functional programming.
*
* Thanks and have fun and remember that we are in alhpa
*/

import type { FunRouterOptions } from "./src/options.ts";

import optimizer from "./src/composer/mainComposer.ts";
import atlas from "./src/framework/builder/atlas/main1.ts";
import split from "./src/framework/builder/atlas/splitter.ts";
import solver from "./src/framework/builder/solver1.ts";
import atlas from "./src/router/atlas/main1.ts";
import split from "./src/router/atlas/splitter.ts";
import solver from "./src/router/solver1.ts";
import type { fileServerPetition, Petition } from "./src/morphism.ts";

/**
* Main function , use in wrap
*/

export default ((o?: FunRouterOptions) => (routes) =>
export default ((o?: FunRouterOptions<any>) =>
(routes: (Petition | fileServerPetition)[]) =>
((re) =>
((map) =>
((s) => (r: Request) => map[s(r)](r))(
((s) => (r: Request): Promise<Response> | Response => map[s(r)](r))(
solver(o)(re),
))([...re[3]]))(
atlas(o)(
Expand Down
58 changes: 15 additions & 43 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import parseArguments from "./components/runtime/parseArguments.ts";
import name from "./components/runtime/name.mjs";
import objectNullRequest from "./components/http/src/optimizer/objectNullRequest.ts";
import {
assertOptions,
assertPlugin,
getName,
getOptions,
} from "./components/http/src/optimizer/pluginUtil.ts";
import checker from "./components/http/src/framework/optimizer/checker.ts";
import resolveComposer from "./components/http/src/optimizer/resolveComposer.ts";
import anyRequest from "./components/http/src/optimizer/anyRequest.ts";
import parseArguments from "./src/runtime/parseArguments.ts";
import name from "./src/runtime/name.ts";

/**
* Runtime utilities
*/

export const runtime = {
name: name,
arguments: parseArguments,
Expand All @@ -23,40 +12,23 @@ export const runtime = {
/**
* Plugins utilities
*/
export const plugins = {
objectNullRequest,
assertOptions,
assertPlugin,
getName,
getOptions,
checker: checker,
anyRequest: anyRequest,
};
/**
* Testing utilities
*/
export const testing = {
resolve: resolveComposer,
//TODO: Improve it
//branch: applyBranch,
};
/**
* @deprecated use composeResponse .
*/
export { default as vixeny } from "./components/http/serve.ts";
export { default as plugins } from "./src/exportable/plugin.ts";

export { default as composeResponse } from "./components/http/serve.ts";
export { wrap } from "./components/http/src/fold/foldMain.ts";
export { default as morphism } from "./components/http/src/optimizer/morphism.ts";
/**
* @deprecated use plugins.assertOptions .
* Petition utilities
*/
export { default as applyBranch } from "./components/http/src/optimizer/branchComposer.ts";

export { petitions } from "./src/morphism.ts";

/**
* @deprecated use plugins.assertOptions .
* Composer utilities
*/
export { default as assertOptions } from "./components/http/src/optimizer/assertOptions.ts";

export { composer } from "./src/exportable/composer.ts";

/**
* @deprecated use plugins.assertPlugin .
* @deprecated use composeResponse .
*/
export { default as assertPlugin } from "./components/http/src/optimizer/assertPlugin.ts";
export { default as vixeny } from "./fun.ts";
export { default as composeResponse } from "./fun.ts";
export { wrap } from "./src/exportable/wrap.ts";
2 changes: 1 addition & 1 deletion src/components/cookieToToken/cookieToTokenMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cookieToTokenBodyParser from "./cookieToTokenBodyParser.ts";
import cookieToTokenGets from "./cookieToTokenGets.ts";
import cookieToTokenFilter from "./cookieToTokenFilter.ts";

export default (o?: FunRouterOptions) => (f: Petition) =>
export default (o?: FunRouterOptions<any>) => (f: Petition) =>
f.crypto && "globalKey" in f.crypto
? (
(getCookies) =>
Expand Down
2 changes: 1 addition & 1 deletion src/components/parameters/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import one from "./one.ts";
import map from "./map.ts";
import unique from "./unique.ts";

export default (options?: FunRouterOptions) => (f: Petition) =>
export default (options?: FunRouterOptions<any>) => (f: Petition) =>
(
(info) =>
f.param && "unique" in f.param && typeof f.param.unique === "boolean" &&
Expand Down
4 changes: 2 additions & 2 deletions src/components/parameters/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FunRouterOptions } from "../../options.ts";
import type { Petition } from "../../morphism.ts";
import type { info } from "./types.ts";

export default (options?: FunRouterOptions) => (f: Petition): info =>
export default (options?: FunRouterOptions<any>) => (f: Petition): info =>
(
(list) => (
((startsWith) =>
Expand All @@ -22,7 +22,7 @@ export default (options?: FunRouterOptions) => (f: Petition): info =>
0,
) + (endsInSlash ? 1 : 0),
endsInSlash: endsInSlash,
hasName: options?.hasName,
bind: options?.indexBase?.bind,
})
)({
tail: list.reduce(
Expand Down
10 changes: 5 additions & 5 deletions src/components/parameters/one.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { info } from "./types.ts";

export default (info: info) =>
info && "hasName" in info && typeof info.hasName === "string"
info && "bind" in info && typeof info.bind === "string"
? `(s => s.indexOf("?") === -1 ? ({${info.elements[0].slice(1)}: s.slice(
${(info.hasName?.length || 0) + info.firstParam}
${(info.bind?.length || 0) + info.firstParam}
${info.lastParam === 0 ? "" : ", -" + info.lastParam})}): ({${
info.elements[0].slice(1)
}: s.slice(${
(info.hasName?.length || 0) + info.firstParam
}, s.indexOf("?") ${info.lastParam === 0 ? "" : " -" + info.lastParam})})
}: s.slice(${(info.bind?.length || 0) + info.firstParam}, s.indexOf("?") ${
info.lastParam === 0 ? "" : " -" + info.lastParam
})})
)`
: `(n =>s=> n !== -1 ? s.indexOf("?") === -1 ?
({${info.elements[0].slice(1)}: s.slice(n ${
Expand Down
6 changes: 3 additions & 3 deletions src/components/parameters/slicer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { info } from "./types.ts";

export default (info: info) =>
info && "hasName" in info && typeof info.hasName === "string"
info && "bind" in info && typeof info.bind === "string"
? `(u => u.indexOf("?") === -1
? u.slice(${(info.hasName?.length || 0) + info.firstParam} ${
? u.slice(${(info.bind?.length || 0) + info.firstParam} ${
info.lastParam === 0 ? "" : ", -" + info.lastParam
})
: u.slice(${
(info.hasName?.length || 0) + info.firstParam
(info.bind?.length || 0) + info.firstParam
}, u.indexOf("?") ${info.lastParam === 0 ? "" : " -" + info.lastParam})
)`
: `(n => u =>
Expand Down
2 changes: 1 addition & 1 deletion src/components/parameters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export type info = {
firstParam: number;
lastParam: number;
endsInSlash: boolean;
hasName: string | undefined;
bind: string | undefined;
};
6 changes: 3 additions & 3 deletions src/components/parameters/unique.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { info } from "./types.ts";

export default (info: info) =>
info && "hasName" in info && typeof info.hasName === "string"
info && "bind" in info && typeof info.bind === "string"
? `s => s.indexOf("?") === -1 ? s.slice(
${(info.hasName?.length || 0) + info.firstParam}
${(info.bind?.length || 0) + info.firstParam}
${info.lastParam === 0 ? "" : ", -" + info.lastParam}): (s.slice(${
(info.hasName?.length || 0) + info.firstParam
(info.bind?.length || 0) + info.firstParam
}, s.indexOf("?") ${info.lastParam === 0 ? "" : " -" + info.lastParam}))`
: `(n =>s=> n !== -1 ? s.indexOf("?") === -1 ?
s.slice(n ${info.lastParam === 0 ? "" : " , - " + info.lastParam}) :
Expand Down
4 changes: 2 additions & 2 deletions src/components/queries/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FunRouterOptions } from "../../options.ts";
import type { Petition } from "../../morphism.ts";

export default (o?: FunRouterOptions) => (f: Petition) =>
export default (o?: FunRouterOptions<any>) => (f: Petition) =>
(
(b) =>
(
Expand Down Expand Up @@ -37,5 +37,5 @@ export default (o?: FunRouterOptions) => (f: Petition) =>
: f.path.length,
)
)(
typeof o?.hasName === "string" ? o.hasName.length : -1,
o?.indexBase?.bind ? o.indexBase.bind.length : -1,
);
2 changes: 1 addition & 1 deletion src/components/queries/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import elements from "./elements.ts";

import filter from "./filter.ts";
import unique from "./unique.ts";
export default (o?: FunRouterOptions) => (f: Petition) =>
export default (o?: FunRouterOptions<any>) => (f: Petition) =>
f.query && "name" in f.query
? new Function(`return ${unique([f.query.name])}`)()
: f.query && "only" in f.query && Array.isArray(f.query.only)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/composer/branch/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default (o?: specialOptions) =>
k(a(r)(b)))(composed)(x.f)
)(
aComposer(o ? { ...o, branch: false } : { branch: false })(x)(
tools.isUsing(o)(x)(tools.elements),
tools.isUsing(o)(x),
),
),
}));
11 changes: 6 additions & 5 deletions src/composer/checkPetition/checkTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ export default {
f.options?.add ?? [],
)),
],
remove: f.options?.remove ?? [],
elements: listOfElements.filter((s) =>
listOfElements.includes(s)
),
remove: (f.options?.remove ?? []),
elements: [
...listOfElements,
...Object.keys(plugins),
],
})
)(
Object.keys(f),
)
)(
[...elements, ...Object.keys(plugins)],
[...elements],
),
};
9 changes: 6 additions & 3 deletions src/composer/checkPetition/mainCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import composerTools from "../composerTools.ts";
import checkParse from "./checkParse.ts";
import checkTool from "./checkTool.ts";

export default (o?: FunRouterOptions) => (f: Petition) =>
"options" in f && f.options
? f.options.only ? f.options.only : (
export default (o?: FunRouterOptions<any>) => (f: Petition) =>
"options" in f && f.options && "only" in f.options &&
Array.isArray(f.options.only)
? f.options.only
: f.options || o?.cyclePlugin
? (
(newOptions) =>
checkParse(newOptions.elements)(newOptions.remove)(newOptions.add)(f)
)(
Expand Down
36 changes: 0 additions & 36 deletions src/composer/checker.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/composer/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import tools from "./composerTools.ts";
import linker from "./linker.ts";
import mime from "../util/mime.ts";

export default (o?: FunRouterOptions) =>
export default (o?: FunRouterOptions<any>) =>
(f: Petition): (ctx: Request) => Promise<Response> | Response =>
((elementsUsed) =>
(
Expand Down Expand Up @@ -90,5 +90,5 @@ export default (o?: FunRouterOptions) =>
: null,
},
))(
tools.isUsing(o)(f)(tools.elements),
tools.isUsing(o)(f),
);
Loading
Loading