5htp-core 0.6.0-93 → 0.6.0-95

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.
@@ -236,9 +236,19 @@ export default ({
236
236
  if (disabled)
237
237
  return false;
238
238
 
239
+ // Custom event
240
+ if (props.onClick !== undefined) {
241
+
242
+ const returned = props.onClick(e);
243
+ if (async && returned?.then) {
244
+ setLoading(true);
245
+ returned.finally(() => setLoading(false));
246
+ }
247
+ }
248
+
239
249
  // Link
240
250
  let nativeEvent: boolean = false;
241
- if ('link' in props) {
251
+ if (('link' in props) && !e.defaultPrevented) {
242
252
 
243
253
  // Nouvelle fenetre = event par defaut
244
254
  if (props.target === '_blank') {
@@ -257,16 +267,6 @@ export default ({
257
267
  }
258
268
  }
259
269
 
260
- // Custom event
261
- if (props.onClick !== undefined) {
262
-
263
- const returned = props.onClick(e);
264
- if (async && returned?.then) {
265
- setLoading(true);
266
- returned.finally(() => setLoading(false));
267
- }
268
- }
269
-
270
270
  if (!nativeEvent) {
271
271
  e.preventDefault();
272
272
  return false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.6.0-93",
4
+ "version": "0.6.0-95",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -14,7 +14,7 @@
14
14
  import type express from 'express';
15
15
  import type { Request, Response, NextFunction } from 'express';
16
16
  import { v4 as uuid } from 'uuid';
17
- import zod from 'zod';
17
+ import zod, { ZodError } from 'zod';
18
18
  export { default as schema } from 'zod';
19
19
  import type { GlobImportedWithMetas } from 'babel-plugin-glob-import';
20
20
 
@@ -23,7 +23,7 @@ import type { Application } from '@server/app';
23
23
  import Service, { AnyService, TServiceArgs } from '@server/app/service';
24
24
  import context from '@server/context';
25
25
  import type DisksManager from '@server/services/disks';
26
- import { CoreError, NotFound, toJson as errorToJson } from '@common/errors';
26
+ import { CoreError, InputError, NotFound, toJson as errorToJson } from '@common/errors';
27
27
  import BaseRouter, {
28
28
  TRoute, TErrorRoute, TRouteModule,
29
29
  TRouteOptions, defaultOptions,
@@ -615,7 +615,12 @@ export default class ServerRouter
615
615
  request.res.json(responseData);
616
616
  }
617
617
 
618
- private async handleError( e: CoreError, request: ServerRequest<ServerRouter> ) {
618
+ private async handleError( e: Error |CoreError | ZodError, request: ServerRequest<ServerRouter> ) {
619
+
620
+ if (e instanceof ZodError)
621
+ e = new InputError(
622
+ e.errors.map(e => e.path.join('.') + ': ' + e.message).join(', ')
623
+ );
619
624
 
620
625
  const code = 'http' in e ? e.http : 500;
621
626
 
@@ -632,7 +637,9 @@ export default class ServerRouter
632
637
 
633
638
  // Don't exose technical errors to users
634
639
  if (this.app.env.profile === 'prod')
635
- e.message = "We encountered an internal error, and our team has just been notified. Sorry for the inconvenience.";
640
+ e = new Error(
641
+ "We encountered an internal error, and our team has just been notified. Sorry for the inconvenience."
642
+ );
636
643
 
637
644
  } else {
638
645
 
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
1
- export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"check-circle"|"coins"|"building"|"at"|"phone"|"bolt"|"brands/linkedin"|"rocket"|"user-circle"|"chart-bar"|"crosshairs"|"plane-departure"|"plus-circle"|"comments-alt"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"calendar-alt"|"paper-plane"|"search"|"lightbulb"|"magnet"|"sun"|"brands/whatsapp"|"user-plus"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"user"|"solid/crown"|"eye"|"pen"|"plus"|"file"|"envelope"|"angle-up"|"angle-down"|"clock"|"cog"|"trash"|"ellipsis-h"|"check"|"binoculars"|"pencil"|"regular/shield-check"|"download"|"exclamation-circle"|"times-circle"|"meh-rolling-eyes"|"arrow-left"|"bars"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"power-off"|"question-circle"|"wind"|"users"|"bug"|"play"|"minus-circle"|"external-link"|"brands/google"|"arrow-to-bottom"|"broom"|"map-marker-alt"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"exclamation-triangle"|"minus"|"plug"|"solid/magic"|"briefcase"|"map-marker"|"fire"|"coin"|"globe"|"comment-alt"|"magic"|"industry"|"calendar"|"graduation-cap"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"unlink"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
1
+ export type TIcones = "long-arrow-right"|"times"|"solid/spinner-third"|"check-circle"|"coins"|"building"|"at"|"phone"|"bolt"|"brands/linkedin"|"rocket"|"chart-bar"|"user-circle"|"plane-departure"|"plus-circle"|"comments-alt"|"arrow-right"|"crosshairs"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"calendar-alt"|"paper-plane"|"user-plus"|"magnet"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"user"|"sun"|"brands/whatsapp"|"search"|"lightbulb"|"angle-up"|"angle-down"|"solid/crown"|"eye"|"pen"|"plus"|"file"|"envelope"|"clock"|"cog"|"trash"|"ellipsis-h"|"check"|"pencil"|"regular/shield-check"|"binoculars"|"download"|"exclamation-circle"|"times-circle"|"arrow-left"|"meh-rolling-eyes"|"bars"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"power-off"|"external-link"|"question-circle"|"play"|"minus-circle"|"wind"|"users"|"bug"|"map-marker-alt"|"arrow-to-bottom"|"broom"|"brands/google"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"exclamation-triangle"|"minus"|"plug"|"comment-alt"|"coin"|"briefcase"|"map-marker"|"fire"|"solid/magic"|"industry"|"calendar"|"globe"|"magic"|"graduation-cap"|"code"|"bold"|"italic"|"underline"|"font"|"strikethrough"|"subscript"|"superscript"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"unlink"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"