create-nara 1.0.40 → 1.0.42

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.

Potentially problematic release.


This version of create-nara might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nara",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "CLI to scaffold NARA projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  import { randomBytes } from 'crypto';
10
10
  import type { NaraRequest, NaraResponse, NaraMiddleware } from '@nara-web/core';
11
11
  import { jsonForbidden } from '@nara-web/core';
12
+ import Logger from '../services/Logger.js';
12
13
 
13
14
  /**
14
15
  * CSRF configuration options
@@ -133,7 +134,7 @@ export function csrf(options: CSRFOptions = {}): NaraMiddleware {
133
134
 
134
135
  // Validate token
135
136
  if (!submittedToken || submittedToken !== token) {
136
- console.warn('[CSRF] Validation failed', {
137
+ Logger.logSecurity('CSRF validation failed', {
137
138
  ip: req.ip,
138
139
  path: req.path,
139
140
  method: req.method,
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { NaraRequest, NaraResponse, NaraMiddleware } from '@nara-web/core';
8
+ import Logger from '../services/Logger.js';
8
9
 
9
10
  /**
10
11
  * Request logger configuration options
@@ -142,13 +143,13 @@ export function requestLogger(options: RequestLoggerOptions = {}): NaraMiddlewar
142
143
 
143
144
  // Log based on level
144
145
  if (level === 'error') {
145
- console.error(`[ERROR] ${message}`, logData);
146
+ Logger.error(message, logData);
146
147
  } else if (level === 'warn') {
147
- console.warn(`[WARN] ${message}`, logData);
148
+ Logger.warn(message, logData);
148
149
  } else if (level === 'debug' || level === 'trace') {
149
- console.debug(`[DEBUG] ${message}`, logData);
150
+ Logger.debug(message, logData);
150
151
  } else {
151
- console.log(`[INFO] ${message}`, logData);
152
+ Logger.info(message, logData);
152
153
  }
153
154
  };
154
155
 
@@ -9,6 +9,7 @@
9
9
  import { randomBytes } from 'crypto';
10
10
  import type { NaraRequest, NaraResponse, NaraMiddleware } from '@nara-web/core';
11
11
  import { jsonForbidden } from '@nara-web/core';
12
+ import Logger from '../services/Logger.js';
12
13
 
13
14
  /**
14
15
  * CSRF configuration options
@@ -133,7 +134,7 @@ export function csrf(options: CSRFOptions = {}): NaraMiddleware {
133
134
 
134
135
  // Validate token
135
136
  if (!submittedToken || submittedToken !== token) {
136
- console.warn('[CSRF] Validation failed', {
137
+ Logger.logSecurity('CSRF validation failed', {
137
138
  ip: req.ip,
138
139
  path: req.path,
139
140
  method: req.method,
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { NaraRequest, NaraResponse, NaraMiddleware } from '@nara-web/core';
8
+ import Logger from '../services/Logger.js';
8
9
 
9
10
  /**
10
11
  * Request logger configuration options
@@ -142,13 +143,13 @@ export function requestLogger(options: RequestLoggerOptions = {}): NaraMiddlewar
142
143
 
143
144
  // Log based on level
144
145
  if (level === 'error') {
145
- console.error(`[ERROR] ${message}`, logData);
146
+ Logger.error(message, logData);
146
147
  } else if (level === 'warn') {
147
- console.warn(`[WARN] ${message}`, logData);
148
+ Logger.warn(message, logData);
148
149
  } else if (level === 'debug' || level === 'trace') {
149
- console.debug(`[DEBUG] ${message}`, logData);
150
+ Logger.debug(message, logData);
150
151
  } else {
151
- console.log(`[INFO] ${message}`, logData);
152
+ Logger.info(message, logData);
152
153
  }
153
154
  };
154
155
 
@@ -35,6 +35,14 @@
35
35
  body: JSON.stringify({ email: form.email, password: form.password })
36
36
  });
37
37
 
38
+ // Check if login was successful via redirect (backend returns 302 on success)
39
+ // fetch follows redirects automatically, so we check if we ended up at dashboard
40
+ if (response.redirected || response.url.endsWith('/dashboard')) {
41
+ Toast('Login successful', 'success');
42
+ router.visit('/dashboard');
43
+ return;
44
+ }
45
+
38
46
  // Handle non-JSON responses (server errors returning HTML)
39
47
  const contentType = response.headers.get('content-type');
40
48
  if (!contentType || !contentType.includes('application/json')) {