@jhits/dashboard 0.0.1 → 0.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jhits/dashboard",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "A comprehensive dashboard system built to manage custom built websites - plugin based SaaS system.",
5
5
  "main": "./src/index.tsx",
6
6
  "types": "./src/index.tsx",
@@ -76,4 +76,4 @@
76
76
  "postcss.config.mjs",
77
77
  "tailwind.config.ts"
78
78
  ]
79
- }
79
+ }
package/src/config.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import 'server-only';
2
+
1
3
  // packages/jhits-dashboard/src/config.ts
2
4
  import type { NextConfig } from "next";
3
5
  import { writeFileSync, mkdirSync, existsSync, readFileSync } from "fs";
package/src/lib/auth.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import 'server-only';
2
+
1
3
  import { NextAuthOptions, Session } from "next-auth";
2
4
  import CredentialsProvider from "next-auth/providers/credentials";
3
5
  import clientPromise from "./mongodb";
@@ -144,8 +146,8 @@ export const authOptions: NextAuthOptions = {
144
146
  error: (code: string, metadata: Error | { [key: string]: unknown; error: Error }) => {
145
147
  // Suppress JWT_SESSION_ERROR for decryption failures (old/invalid cookies)
146
148
  if (code === 'JWT_SESSION_ERROR') {
147
- const errorMessage = metadata instanceof Error
148
- ? metadata.message
149
+ const errorMessage = metadata instanceof Error
150
+ ? metadata.message
149
151
  : (metadata as { message?: string })?.message || '';
150
152
  if (errorMessage.includes('decryption')) {
151
153
  // Silently ignore - user will need to log in again
package/src/lib/db.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import 'server-only';
2
+
1
3
  // apps/dashboard/lib/db.ts
2
4
 
3
5
  // Mock implementation - Replace with your actual database call (Prisma, Drizzle, Supabase, etc.)
@@ -1,3 +1,5 @@
1
+ import 'server-only';
2
+
1
3
  import { headers } from 'next/headers';
2
4
  import type { WebsiteInfo } from './website-context';
3
5
  import clientPromise from './mongodb';
@@ -12,39 +14,39 @@ export async function getWebsiteInfo(locale: string): Promise<WebsiteInfo> {
12
14
  try {
13
15
  const headersList = await headers();
14
16
  const host = headersList.get('host') || '';
15
- const protocol = headersList.get('x-forwarded-proto') ||
16
- (process.env.NODE_ENV === 'production' ? 'https' : 'http');
17
-
17
+ const protocol = headersList.get('x-forwarded-proto') ||
18
+ (process.env.NODE_ENV === 'production' ? 'https' : 'http');
19
+
18
20
  // Get website info from headers (set by host app's middleware)
19
- const siteName = headersList.get('x-site-name') ||
20
- process.env.NEXT_PUBLIC_SITE_NAME ||
21
- 'Website';
22
- const siteTagline = headersList.get('x-site-tagline') ||
23
- process.env.NEXT_PUBLIC_SITE_TAGLINE ||
24
- '';
25
-
21
+ const siteName = headersList.get('x-site-name') ||
22
+ process.env.NEXT_PUBLIC_SITE_NAME ||
23
+ 'Website';
24
+ const siteTagline = headersList.get('x-site-tagline') ||
25
+ process.env.NEXT_PUBLIC_SITE_TAGLINE ||
26
+ '';
27
+
26
28
  // Construct the base URL for the website home page
27
29
  const baseUrl = `${protocol}://${host}`;
28
30
  const homeUrl = locale === 'en' ? baseUrl : `${baseUrl}/${locale}`;
29
-
31
+
30
32
  // Try to fetch logo from client app's settings
31
33
  let logo: { light: string; dark: string } | undefined;
32
34
  try {
33
35
  const client = await clientPromise;
34
36
  const db = client.db();
35
37
  const settings = await db.collection("settings").findOne({ identifier: "site_config" });
36
-
38
+
37
39
  if (settings) {
38
40
  // Check if logo paths are stored in settings
39
41
  // Common patterns: LogoIcon.svg, LogoIcon-inverted.svg, or custom paths
40
42
  // Also check for common logo file names used in client apps
41
- const logoLight = settings.logoLight ||
42
- settings.logo?.light ||
43
- '/LogoIcon.svg';
44
- const logoDark = settings.logoDark ||
45
- settings.logo?.dark ||
46
- '/LogoIcon-inverted.svg';
47
-
43
+ const logoLight = settings.logoLight ||
44
+ settings.logo?.light ||
45
+ '/LogoIcon.svg';
46
+ const logoDark = settings.logoDark ||
47
+ settings.logo?.dark ||
48
+ '/LogoIcon-inverted.svg';
49
+
48
50
  // Only set logo if at least one path exists
49
51
  if (logoLight || logoDark) {
50
52
  logo = {
@@ -57,7 +59,7 @@ export async function getWebsiteInfo(locale: string): Promise<WebsiteInfo> {
57
59
  // If database fetch fails, continue without logo
58
60
  console.warn('Failed to fetch logo from settings:', dbError);
59
61
  }
60
-
62
+
61
63
  return {
62
64
  name: siteName,
63
65
  tagline: siteTagline,
@@ -1,3 +1,5 @@
1
+ import 'server-only';
2
+
1
3
  // src/lib/modules-config.ts
2
4
  import { BarChart3, Newspaper, Globe, Users, Mail, type LucideIcon } from 'lucide-react';
3
5
 
@@ -1,3 +1,5 @@
1
+ import 'server-only';
2
+
1
3
  import { MongoClient } from 'mongodb';
2
4
 
3
5
  // Support both DATABASE_URL (dashboard) and MONGODB_URI (client app)
package/src/server.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import 'server-only';
2
+
1
3
  /**
2
4
  * Server-only exports for @jhits/dashboard
3
5
  * These exports should only be used in server-side code (API routes, server components)