@lolyjs/core 0.2.0-alpha.7 → 0.2.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +31 -31
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -7,8 +7,11 @@
7
7
  [![npm version](https://img.shields.io/npm/v/@lolyjs/core?style=flat-square)](https://www.npmjs.com/package/@lolyjs/core)
8
8
  [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg?style=flat-square)](https://opensource.org/licenses/ISC)
9
9
  ![Downloads](https://img.shields.io/npm/dm/@lolyjs/core)
10
+ <br>
11
+ [![Alpha](https://img.shields.io/badge/status-alpha-red.svg)](https://github.com/MenvielleValen/loly-framework)
12
+ [![Expermiental](https://img.shields.io/badge/phase-experimental-black.svg)](https://github.com/MenvielleValen/loly-framework)
10
13
 
11
- *Built with React 19, Express, Rspack, Socket.IO, and TypeScript*
14
+ _Built with React 19, Express, Rspack, Socket.IO, and TypeScript_
12
15
 
13
16
  </div>
14
17
 
@@ -68,7 +71,7 @@ import type { ServerLoader } from "@lolyjs/core";
68
71
 
69
72
  export const getServerSideProps: ServerLoader = async (ctx) => {
70
73
  const data = await fetchData();
71
-
74
+
72
75
  return {
73
76
  props: { data },
74
77
  metadata: {
@@ -144,6 +147,7 @@ socket.emit("message", { text: "Hello!" });
144
147
  ```
145
148
 
146
149
  **Key Benefits:**
150
+
147
151
  - Automatic namespace creation from file structure
148
152
  - Same routing pattern as pages and APIs
149
153
  - Built-in broadcasting helpers (`emit`, `broadcast`, `emitTo`, `emitToClient`)
@@ -209,6 +213,7 @@ export async function GET(ctx: ApiContext) {
209
213
  ```
210
214
 
211
215
  **Key Benefits:**
216
+
212
217
  - Middlewares execute before loaders/handlers
213
218
  - Share data via `ctx.locals`
214
219
  - Method-specific middlewares for APIs
@@ -218,11 +223,11 @@ export async function GET(ctx: ApiContext) {
218
223
 
219
224
  Routes are automatically created from your file structure:
220
225
 
221
- | File Path | Route |
222
- |-----------|-------|
223
- | `app/page.tsx` | `/` |
224
- | `app/about/page.tsx` | `/about` |
225
- | `app/blog/[slug]/page.tsx` | `/blog/:slug` |
226
+ | File Path | Route |
227
+ | ----------------------------- | --------------------- |
228
+ | `app/page.tsx` | `/` |
229
+ | `app/about/page.tsx` | `/about` |
230
+ | `app/blog/[slug]/page.tsx` | `/blog/:slug` |
226
231
  | `app/post/[...path]/page.tsx` | `/post/*` (catch-all) |
227
232
 
228
233
  **Nested Layouts:**
@@ -278,7 +283,7 @@ export const dynamic = "force-static" as const;
278
283
 
279
284
  export const generateStaticParams: GenerateStaticParams = async () => {
280
285
  const posts = await getAllPosts();
281
- return posts.map(post => ({ slug: post.slug }));
286
+ return posts.map((post) => ({ slug: post.slug }));
282
287
  };
283
288
 
284
289
  export const getServerSideProps: ServerLoader = async (ctx) => {
@@ -295,11 +300,11 @@ import { useState, useEffect } from "react";
295
300
 
296
301
  export default function Dashboard() {
297
302
  const [data, setData] = useState(null);
298
-
303
+
299
304
  useEffect(() => {
300
305
  fetchData().then(setData);
301
306
  }, []);
302
-
307
+
303
308
  return <div>{data}</div>;
304
309
  }
305
310
  ```
@@ -440,10 +445,10 @@ import type { ServerLoader } from "@lolyjs/core";
440
445
 
441
446
  export const getServerSideProps: ServerLoader = async (ctx) => {
442
447
  const { req, res, params, pathname, locals } = ctx;
443
-
448
+
444
449
  // Fetch data
445
450
  const data = await fetchData();
446
-
451
+
447
452
  // Redirect
448
453
  return {
449
454
  redirect: {
@@ -451,10 +456,10 @@ export const getServerSideProps: ServerLoader = async (ctx) => {
451
456
  permanent: true,
452
457
  },
453
458
  };
454
-
459
+
455
460
  // Not found
456
461
  return { notFound: true };
457
-
462
+
458
463
  // Return props
459
464
  return {
460
465
  props: { data },
@@ -500,13 +505,13 @@ export const events = [
500
505
  name: "custom-event",
501
506
  handler: (ctx: WssContext) => {
502
507
  const { socket, data, actions } = ctx;
503
-
508
+
504
509
  // Emit to all clients
505
510
  actions.emit("response", { message: "Hello" });
506
-
511
+
507
512
  // Broadcast to all except sender
508
513
  actions.broadcast("notification", data);
509
-
514
+
510
515
  // Emit to specific socket
511
516
  actions.emitTo(socketId, "private", data);
512
517
  },
@@ -522,11 +527,11 @@ import { revalidate } from "@lolyjs/core/client-cache";
522
527
 
523
528
  export default function Page() {
524
529
  const { params, props } = usePageProps();
525
-
530
+
526
531
  const handleRefresh = async () => {
527
532
  await revalidate(); // Refresh current page data
528
533
  };
529
-
534
+
530
535
  return <div>{/* Your UI */}</div>;
531
536
  }
532
537
  ```
@@ -595,9 +600,7 @@ import { ServerConfig } from "@lolyjs/core";
595
600
  export const config = (env: string): ServerConfig => {
596
601
  return {
597
602
  bodyLimit: "1mb",
598
- corsOrigin: env === "production"
599
- ? ["https://yourdomain.com"]
600
- : "*",
603
+ corsOrigin: env === "production" ? ["https://yourdomain.com"] : "*",
601
604
  rateLimit: {
602
605
  windowMs: 15 * 60 * 1000,
603
606
  max: 1000,
@@ -623,10 +626,10 @@ export async function init({
623
626
  }) {
624
627
  // Initialize database connection
625
628
  await connectToDatabase();
626
-
629
+
627
630
  // Setup external services
628
631
  await setupExternalServices();
629
-
632
+
630
633
  // Any other initialization logic
631
634
  console.log("Server initialized successfully");
632
635
  }
@@ -678,6 +681,7 @@ npm run build
678
681
  ```
679
682
 
680
683
  This generates:
684
+
681
685
  - Client bundle (`.loly/client`)
682
686
  - Static pages if using SSG (`.loly/ssg`)
683
687
  - Server code (`.loly/server`)
@@ -715,18 +719,14 @@ import { validate, safeValidate, ValidationError } from "@lolyjs/core";
715
719
 
716
720
  // Security
717
721
  import { sanitizeString, sanitizeObject } from "@lolyjs/core";
718
- import {
722
+ import {
719
723
  createRateLimiter,
720
724
  defaultRateLimiter,
721
- strictRateLimiter
725
+ strictRateLimiter,
722
726
  } from "@lolyjs/core";
723
727
 
724
728
  // Logging
725
- import {
726
- logger,
727
- createModuleLogger,
728
- getRequestLogger
729
- } from "@lolyjs/core";
729
+ import { logger, createModuleLogger, getRequestLogger } from "@lolyjs/core";
730
730
 
731
731
  // Client
732
732
  import { Link } from "@lolyjs/core/components";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@lolyjs/core",
3
3
  "author": "LolyJS",
4
4
  "description": "Loly Core is an experimental React framework with file-based routing, SSR/SSG features, native WebSocket support, and an Express-powered backend. It’s currently in alpha and intended for learning, prototyping, and early experimentation.",
5
- "version": "0.2.0-alpha.7",
5
+ "version": "0.2.0-alpha.8",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",