v0.0.0.6
🌐 Vixeny: At the forefront of modern web development, Vixeny stands as a runtime-independent, efficiency-driven library dedicated to upholding the principles of functional purity. It's crafted to empower developers with a robust foundation for creating scalable, maintainable, and high-performance web applications.
Repository
Current version released
2 years ago
Versions
- v0.1.43Latest
- v0.1.30
- v0.1.21
- v0.1.20
- v0.1.10
- v0.1.0
- v0.0.950
- v0.0.945
- v0.0.941
- v0.0.94
- v0.0.932
- v0.0.927
- v0.0.926
- v0.0.922
- v0.0.921
- v0.0.92
- v.0.0.9
- v0.0.89
- v0.0.87
- v0.0.84
- v0.0.773
- v0.0.7
- v0.0.682
- v0.0.681
- v0.0.675
- v0.0.67
- v0.0.66
- v0.0661
- v0.0.65
- v0.0.64
- v0.0.63
- v0.0.62
- v0.0.61
- v0.0.6
- v0.0.56
- v0.0.4.0
- v0.0.3.0
- v0.0.2.3
- v0.0.2.2
- v0.0.2.1
- v0.0.2.0
- v0.0.1.91
- v0.0.1.9
- v0.0.1.1
- v0.0.1.0
- v0.0.0.99
- v0.0.0.71
- v0.0.0.7
- v0.0.0.65
- v0.0.0.6
- v0.0.0.5
- v0.0.0.4
- v0.0.0.3
- v0.0.0.2
Endofunctor
Do you have any ideas? Go to discussions and tell me what you need
in-progress | next |
---|---|
Coverage | Session |
Debugging | Signer |
About
Endofunctor is:
- Independent
- Fast
- Scalable
- Predictable
- Functional
Benchmark
Faster than Hono / Endofunctor vs. Hono
Get started in 10 Minutes!
Get Endofunctor and a server
//Endofunctor is just a router, so a server that gives a Request and expects a Response is needed
import { serve } from "https://deno.land/std@0.159.0/http/server.ts";
// import fun
import fun from "https://deno.land/x/endofunctor/fun.ts";
Give a path and a function
// the function has to return a valid BodyInt or Promise<BodyInit>
await serve(
fun()([
{
path: "/",
f: (_) => "hello world",
},
]),
{ port: 8080 },
);
Add parameters, a query, a status, or a header!
// the router auto-detect if you are using (parameters, querries, or Request ) unless you send the arguments out of the scope
// r: (arguments) => outOfScope(arguments),
// you can add or remove them with "add", "delete"
await serve(
fun(
{ hasName: "http://127.0.0.1:8080/" },
)([
{
path: "/test/:id",
status: 201,
header: ".html", // { 'Content-Type' : 'text/html'}
f: (f) => f.param.id + " " + (f.query?.hello || ""),
},
]),
{ port: 8080, hostname: "127.0.0.1" },
);
Parameters
Parameters must be chained, without gaps.
// valid (It is important to note that the following routes are different)
"/hello/:id"
"/hello/:id/"
"/hello/:id/:page/:time"
"/hello/:id/:page/:time/"
// invalid
"/hello/:id/page/:time"
"/hello/:id/page/:time/"
Do you need more control?
// use the type: "request" to return a Response or Promise<Response>
// you can use params and query here too!
await serve(
fun(
{ hasName: "http://127.0.0.1:8080/" },
)([
{
type: "request",
path: "/abc",
f: (f) => new Response(f.query?.hello || "abc"),
},
]),
{ port: 8080, hostname: "127.0.0.1" },
);
Do you need Functor just to route your function? I’ve got you covered!
// use the type: "response" to return a Response or Promise<Response>
await serve(
fun(
{ hasName: "http://127.0.0.1:8080/" },
)([
{
type: "response",
path: "/",
r: (_) => new Response("hello world"),
}, ]),
{ port: 8080, hostname: "127.0.0.1" },
);
Static file is natively built in Endofunctor!
// "path" is relative to the terminal
// remove mime types with mime:false
// add mime with extra: [ [header, extension]]
await serve(
fun(
{ hasName: "http://127.0.0.1:8080/" },
)([
{
type: "static",
name: "/s",
path: "./",
},
, ]),
{ port: 8080, hostname: "127.0.0.1" },
);
Thanks and have fun ~
Specifications
Route options
type funRouterOptions = {
hasName?: string;
paramsStartsWith?: string;
notFound?: { (x: Request): Response };
badMethod?: { (x: Request): Response };
};
“hasName”: is the name of the server, and it always has to finish with “/” , example: “http://127.0.0.1:8080/”, the router will be 5% faster if a name is given.
“paramsStartsWith”: by default, a parameter is defined by “:” next to a “/”, changing this value, will take the first character and check if it’s follow by “/” to start a new parameter.
“notFound”: changes the default NOT_FOUND.
“badMethod”: changes the default BAD_METHOD.
Methods
There are four methods
type ParamsMethod = "GET" | "HEAD" | "POST" | "DELETE";