···11+const server = Bun.serve({
22+ async fetch(req) {
33+ const url = new URL(req.url);
44+ const filePath = `./server${url.pathname}`;
55+66+ const file = Bun.file(filePath);
77+ const exists = await file.exists();
88+ if (exists) {
99+ return new Response(file);
1010+ }
1111+1212+ return new Response("Not Found", { status: 404 });
1313+ },
1414+ port: 3000,
1515+ hostname: "0.0.0.0",
1616+});
1717+1818+console.log(`Server running at ${server.url}`);
1919+console.log(`Access from your network at http://192.168.1.41:${server.port}`);
+38-40
src/ewe.gleam
···8484//// ]
8585//// }
8686//// ]
8787-////
8787+////
8888//// const callback = () => {
8989//// const list = document.querySelector(".sidebar > ul:last-of-type")
9090//// const sortedLists = document.createDocumentFragment()
9191//// const sortedMembers = document.createDocumentFragment()
9292-////
9292+////
9393//// for (const section of docs) {
9494//// sortedLists.append((() => {
9595//// const node = document.createElement("h3")
···101101//// node.append(section.header)
102102//// return node
103103//// })())
104104-////
104104+////
105105//// const sortedList = document.createElement("ul")
106106//// sortedLists.append(sortedList)
107107-////
107107+////
108108//// const sortedFunctions = [...section.functions].sort()
109109-////
109109+////
110110//// for (const funcName of sortedFunctions) {
111111//// const href = `#${funcName}`
112112//// const member = document.querySelector(
···117117//// sortedMembers.append(member)
118118//// }
119119//// }
120120-////
120120+////
121121//// document.querySelector(".sidebar").insertBefore(sortedLists, list)
122122//// document
123123//// .querySelector(".module-members:has(#module-values)")
···126126//// document.querySelector("#module-values").nextSibling
127127//// )
128128//// }
129129-////
129129+////
130130//// document.readyState !== "loading"
131131//// ? callback()
132132//// : document.addEventListener(
···135135//// { once: true }
136136//// )
137137//// </script>
138138-139139-// -----------------------------------------------------------------------------
140140-// IMPORTS
141141-// -----------------------------------------------------------------------------
142138143139import ewe/internal/file
144140import ewe/internal/handler
···192188///
193189pub fn ip_address_to_string(address address: IpAddress) -> String {
194190 ewe_to_glisten_ip(address)
195195- |> glisten.ip_address_to_string()
191191+ |> glisten.ip_address_to_string
196192}
197193198194fn glisten_to_ewe_ip(ip: glisten.IpAddress) -> IpAddress {
···618614///
619615pub type BodyError {
620616 /// Body is larger than the provided limit.
617617+ ///
621618 BodyTooLarge
622619 /// Body is malformed.
620620+ ///
623621 InvalidBody
624622}
625623···691689// CHUNKED RESPONSE
692690// -----------------------------------------------------------------------------
693691694694-/// Represents a chunked response body. This type is used to send a chunked
692692+/// Represents a chunked response body. This type is used to send a chunked
695693/// response to the client.
696696-///
694694+///
697695pub type ChunkedBody =
698696 chunked.ChunkedBody
699697···710708}
711709712710/// Instructs chunked response to continue processing.
713713-///
711711+///
714712pub fn chunked_continue(user_state: user_state) -> ChunkedNext(user_state) {
715713 ChunkedContinue(user_state)
716714}
···738736}
739737740738/// Sets up the connection for chunked response.
741741-///
742742-/// `on_init` function is called once the chunked response process is
743743-/// initialized. The argument is subject that can be used to send chunks to the
739739+///
740740+/// `on_init` function is called once the chunked response process is
741741+/// initialized. The argument is subject that can be used to send chunks to the
744742/// client. It must return initial state.
745743///
746744/// `handler` function is called for every message received. It must return
···992990 )
993991}
994992995995-/// WebSocket close codes that can be sent when closing a connection. The `data`
996996-/// parameter allows you to include payload up to 123 bytes in size.
997997-///
993993+/// WebSocket close codes that can be sent when closing a connection. The `data`
994994+/// parameter allows you to include payload up to 123 bytes in size.
995995+///
998996pub type CloseCode {
999999- /// Standard graceful shutdown (1000). Use when connection completed
997997+ /// Standard graceful shutdown (1000). Use when connection completed
1000998 /// successfully.
10011001- ///
999999+ ///
10021000 NormalClosure(data: String)
10031003- /// Invalid message format (1007). Received payload that doesn't match what
10011001+ /// Invalid message format (1007). Received payload that doesn't match what
10041002 /// you expected.
10051005- ///
10031003+ ///
10061004 InvalidPayloadData(data: String)
10071005 /// Application policy violation (1008).Client broke your rules - failed
10081006 /// authentication, hit rate limits, or violated business logic.
10091009- ///
10071007+ ///
10101008 PolicyViolation(data: String)
10111011- /// Message exceeds size limits (1009). Client sent something bigger than
10091009+ /// Message exceeds size limits (1009). Client sent something bigger than
10121010 /// your application allows.
10131013- ///
10111011+ ///
10141012 MessageTooBig(data: String)
10151015- /// Server encountered unexpected error (1011). Something went wrong on your
10131013+ /// Server encountered unexpected error (1011). Something went wrong on your
10161014 /// side that prevents handling the connection.
10171017- ///
10151015+ ///
10181016 InternalError(data: String)
10191019- /// Server is restarting (1012). Planned restart - clients can reconnect
10171017+ /// Server is restarting (1012). Planned restart - clients can reconnect
10201018 /// after a bit.
10211021- ///
10191019+ ///
10221020 ServiceRestart(data: String)
10231023- /// Temporary server overload (1013). Use when server is temporarily
10211021+ /// Temporary server overload (1013). Use when server is temporarily
10241022 /// unavailable, client should retry.
10251025- ///
10231023+ ///
10261024 TryAgainLater(data: String)
10271027- /// Gateway/proxy received invalid response (1014). You're acting as a proxy
10251025+ /// Gateway/proxy received invalid response (1014). You're acting as a proxy
10281026 /// and the upstream server gave you garbage.
10291029- ///
10271027+ ///
10301028 BadGateway(data: String)
10311029 /// Custom close codes 3000-4999 for application-specific use.
10321032- ///
10301030+ ///
10331031 CustomCloseCode(code: Int, data: String)
10341032 /// Close without a specific reason.
10351035- ///
10331033+ ///
10361034 NoCloseReason
10371035}
10381036···11201118/// - `id`: event ID.
11211119/// - `retry`: The reconnection time. If the connection to the server is lost,
11221120/// the browser will wait for the specified time before attempting to reconnect.
11231123-///
11211121+///
11241122/// Can be created using `ewe.event` and modified with `ewe.event_name`,
11251123/// `ewe.event_id`, and `ewe.event_retry`.
11261124///
···11601158///
11611159/// `handler` function is called for every subject's message received. It must
11621160/// return instruction on how SSE connection should proceed.
11631163-///
11611161+///
11641162/// `on_close` function is called when SSE process is going to be stopped.
11651163///
11661164pub fn sse(