@lolyjs/core 0.2.0-alpha.6 → 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 +32 -31
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,8 +6,12 @@
6
6
 
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
+ ![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)
9
13
 
10
- *Built with React 19, Express, Rspack, Socket.IO, and TypeScript*
14
+ _Built with React 19, Express, Rspack, Socket.IO, and TypeScript_
11
15
 
12
16
  </div>
13
17
 
@@ -67,7 +71,7 @@ import type { ServerLoader } from "@lolyjs/core";
67
71
 
68
72
  export const getServerSideProps: ServerLoader = async (ctx) => {
69
73
  const data = await fetchData();
70
-
74
+
71
75
  return {
72
76
  props: { data },
73
77
  metadata: {
@@ -143,6 +147,7 @@ socket.emit("message", { text: "Hello!" });
143
147
  ```
144
148
 
145
149
  **Key Benefits:**
150
+
146
151
  - Automatic namespace creation from file structure
147
152
  - Same routing pattern as pages and APIs
148
153
  - Built-in broadcasting helpers (`emit`, `broadcast`, `emitTo`, `emitToClient`)
@@ -208,6 +213,7 @@ export async function GET(ctx: ApiContext) {
208
213
  ```
209
214
 
210
215
  **Key Benefits:**
216
+
211
217
  - Middlewares execute before loaders/handlers
212
218
  - Share data via `ctx.locals`
213
219
  - Method-specific middlewares for APIs
@@ -217,11 +223,11 @@ export async function GET(ctx: ApiContext) {
217
223
 
218
224
  Routes are automatically created from your file structure:
219
225
 
220
- | File Path | Route |
221
- |-----------|-------|
222
- | `app/page.tsx` | `/` |
223
- | `app/about/page.tsx` | `/about` |
224
- | `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` |
225
231
  | `app/post/[...path]/page.tsx` | `/post/*` (catch-all) |
226
232
 
227
233
  **Nested Layouts:**
@@ -277,7 +283,7 @@ export const dynamic = "force-static" as const;
277
283
 
278
284
  export const generateStaticParams: GenerateStaticParams = async () => {
279
285
  const posts = await getAllPosts();
280
- return posts.map(post => ({ slug: post.slug }));
286
+ return posts.map((post) => ({ slug: post.slug }));
281
287
  };
282
288
 
283
289
  export const getServerSideProps: ServerLoader = async (ctx) => {
@@ -294,11 +300,11 @@ import { useState, useEffect } from "react";
294
300
 
295
301
  export default function Dashboard() {
296
302
  const [data, setData] = useState(null);
297
-
303
+
298
304
  useEffect(() => {
299
305
  fetchData().then(setData);
300
306
  }, []);
301
-
307
+
302
308
  return <div>{data}</div>;
303
309
  }
304
310
  ```
@@ -439,10 +445,10 @@ import type { ServerLoader } from "@lolyjs/core";
439
445
 
440
446
  export const getServerSideProps: ServerLoader = async (ctx) => {
441
447
  const { req, res, params, pathname, locals } = ctx;
442
-
448
+
443
449
  // Fetch data
444
450
  const data = await fetchData();
445
-
451
+
446
452
  // Redirect
447
453
  return {
448
454
  redirect: {
@@ -450,10 +456,10 @@ export const getServerSideProps: ServerLoader = async (ctx) => {
450
456
  permanent: true,
451
457
  },
452
458
  };
453
-
459
+
454
460
  // Not found
455
461
  return { notFound: true };
456
-
462
+
457
463
  // Return props
458
464
  return {
459
465
  props: { data },
@@ -499,13 +505,13 @@ export const events = [
499
505
  name: "custom-event",
500
506
  handler: (ctx: WssContext) => {
501
507
  const { socket, data, actions } = ctx;
502
-
508
+
503
509
  // Emit to all clients
504
510
  actions.emit("response", { message: "Hello" });
505
-
511
+
506
512
  // Broadcast to all except sender
507
513
  actions.broadcast("notification", data);
508
-
514
+
509
515
  // Emit to specific socket
510
516
  actions.emitTo(socketId, "private", data);
511
517
  },
@@ -521,11 +527,11 @@ import { revalidate } from "@lolyjs/core/client-cache";
521
527
 
522
528
  export default function Page() {
523
529
  const { params, props } = usePageProps();
524
-
530
+
525
531
  const handleRefresh = async () => {
526
532
  await revalidate(); // Refresh current page data
527
533
  };
528
-
534
+
529
535
  return <div>{/* Your UI */}</div>;
530
536
  }
531
537
  ```
@@ -594,9 +600,7 @@ import { ServerConfig } from "@lolyjs/core";
594
600
  export const config = (env: string): ServerConfig => {
595
601
  return {
596
602
  bodyLimit: "1mb",
597
- corsOrigin: env === "production"
598
- ? ["https://yourdomain.com"]
599
- : "*",
603
+ corsOrigin: env === "production" ? ["https://yourdomain.com"] : "*",
600
604
  rateLimit: {
601
605
  windowMs: 15 * 60 * 1000,
602
606
  max: 1000,
@@ -622,10 +626,10 @@ export async function init({
622
626
  }) {
623
627
  // Initialize database connection
624
628
  await connectToDatabase();
625
-
629
+
626
630
  // Setup external services
627
631
  await setupExternalServices();
628
-
632
+
629
633
  // Any other initialization logic
630
634
  console.log("Server initialized successfully");
631
635
  }
@@ -677,6 +681,7 @@ npm run build
677
681
  ```
678
682
 
679
683
  This generates:
684
+
680
685
  - Client bundle (`.loly/client`)
681
686
  - Static pages if using SSG (`.loly/ssg`)
682
687
  - Server code (`.loly/server`)
@@ -714,18 +719,14 @@ import { validate, safeValidate, ValidationError } from "@lolyjs/core";
714
719
 
715
720
  // Security
716
721
  import { sanitizeString, sanitizeObject } from "@lolyjs/core";
717
- import {
722
+ import {
718
723
  createRateLimiter,
719
724
  defaultRateLimiter,
720
- strictRateLimiter
725
+ strictRateLimiter,
721
726
  } from "@lolyjs/core";
722
727
 
723
728
  // Logging
724
- import {
725
- logger,
726
- createModuleLogger,
727
- getRequestLogger
728
- } from "@lolyjs/core";
729
+ import { logger, createModuleLogger, getRequestLogger } from "@lolyjs/core";
729
730
 
730
731
  // Client
731
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.6",
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",