@jhits/plugin-website 0.0.15 → 0.0.16

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.
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/api/handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,wBAAsB,YAAY,CAC9B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC,CAuDvB;AAED;;GAEG;AACH,wBAAsB,aAAa,CAC/B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC,CAmFvB"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/api/handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,wBAAsB,YAAY,CAC9B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC,CAuDvB;AAED;;GAEG;AACH,wBAAsB,aAAa,CAC/B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC,CAuDvB"}
@@ -69,12 +69,6 @@ export async function POST_SETTINGS(req, config) {
69
69
  return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
70
70
  }
71
71
  const body = await req.json();
72
- console.log('[WebsiteAPI] POST_SETTINGS received body:', {
73
- launch_date: body.launch_date,
74
- launch_date_type: typeof body.launch_date,
75
- has_launch_date: 'launch_date' in body,
76
- body_keys: Object.keys(body),
77
- });
78
72
  const dbConnection = await config.getDb();
79
73
  const db = dbConnection.db();
80
74
  const settings = db.collection('settings');
@@ -92,39 +86,19 @@ export async function POST_SETTINGS(req, config) {
92
86
  if (launch_date !== undefined && launch_date !== null && launch_date !== '') {
93
87
  // Convert launch_date from datetime-local string to Date if provided
94
88
  const date = new Date(launch_date);
95
- console.log('[WebsiteAPI] Date conversion:', {
96
- input: launch_date,
97
- parsed: date,
98
- isValid: !isNaN(date.getTime()),
99
- iso: !isNaN(date.getTime()) ? date.toISOString() : 'invalid',
100
- });
101
89
  if (!isNaN(date.getTime())) {
102
90
  updateOps.$set.launch_date = date;
103
- console.log('[WebsiteAPI] Setting launch_date to:', date.toISOString());
104
91
  }
105
92
  else {
106
- console.warn('[WebsiteAPI] Invalid date, removing launch_date field');
107
93
  updateOps.$unset = { launch_date: '' };
108
94
  }
109
95
  }
110
96
  else {
111
97
  // Remove launch_date field if it's empty, undefined, or null
112
- console.log('[WebsiteAPI] launch_date is empty/undefined, removing field');
113
98
  updateOps.$unset = { launch_date: '' };
114
99
  }
115
- console.log('[WebsiteAPI] Update operations:', JSON.stringify(updateOps, (key, value) => {
116
- if (value instanceof Date) {
117
- return value.toISOString();
118
- }
119
- return value;
120
- }, 2));
121
100
  // Upsert settings
122
- const result = await settings.updateOne({ identifier: 'site_config' }, updateOps, { upsert: true });
123
- console.log('[WebsiteAPI] Update result:', {
124
- matchedCount: result.matchedCount,
125
- modifiedCount: result.modifiedCount,
126
- upsertedCount: result.upsertedCount,
127
- });
101
+ await settings.updateOne({ identifier: 'site_config' }, updateOps, { upsert: true });
128
102
  return NextResponse.json({ success: true, message: 'Settings updated successfully' });
129
103
  }
130
104
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jhits/plugin-website",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Website management and configuration plugin for the JHITS ecosystem",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -88,12 +88,6 @@ export async function POST_SETTINGS(
88
88
  }
89
89
 
90
90
  const body = await req.json();
91
- console.log('[WebsiteAPI] POST_SETTINGS received body:', {
92
- launch_date: body.launch_date,
93
- launch_date_type: typeof body.launch_date,
94
- has_launch_date: 'launch_date' in body,
95
- body_keys: Object.keys(body),
96
- });
97
91
 
98
92
  const dbConnection = await config.getDb();
99
93
  const db = dbConnection.db();
@@ -115,46 +109,24 @@ export async function POST_SETTINGS(
115
109
  if (launch_date !== undefined && launch_date !== null && launch_date !== '') {
116
110
  // Convert launch_date from datetime-local string to Date if provided
117
111
  const date = new Date(launch_date);
118
- console.log('[WebsiteAPI] Date conversion:', {
119
- input: launch_date,
120
- parsed: date,
121
- isValid: !isNaN(date.getTime()),
122
- iso: !isNaN(date.getTime()) ? date.toISOString() : 'invalid',
123
- });
124
112
 
125
113
  if (!isNaN(date.getTime())) {
126
114
  updateOps.$set.launch_date = date;
127
- console.log('[WebsiteAPI] Setting launch_date to:', date.toISOString());
128
115
  } else {
129
- console.warn('[WebsiteAPI] Invalid date, removing launch_date field');
130
116
  updateOps.$unset = { launch_date: '' };
131
117
  }
132
118
  } else {
133
119
  // Remove launch_date field if it's empty, undefined, or null
134
- console.log('[WebsiteAPI] launch_date is empty/undefined, removing field');
135
120
  updateOps.$unset = { launch_date: '' };
136
121
  }
137
122
 
138
- console.log('[WebsiteAPI] Update operations:', JSON.stringify(updateOps, (key, value) => {
139
- if (value instanceof Date) {
140
- return value.toISOString();
141
- }
142
- return value;
143
- }, 2));
144
-
145
123
  // Upsert settings
146
- const result = await settings.updateOne(
124
+ await settings.updateOne(
147
125
  { identifier: 'site_config' },
148
126
  updateOps,
149
127
  { upsert: true }
150
128
  );
151
129
 
152
- console.log('[WebsiteAPI] Update result:', {
153
- matchedCount: result.matchedCount,
154
- modifiedCount: result.modifiedCount,
155
- upsertedCount: result.upsertedCount,
156
- });
157
-
158
130
  return NextResponse.json({ success: true, message: 'Settings updated successfully' });
159
131
  } catch (error: any) {
160
132
  console.error('[WebsiteAPI] POST_SETTINGS error:', error);
@@ -164,4 +136,3 @@ export async function POST_SETTINGS(
164
136
  );
165
137
  }
166
138
  }
167
-