silgi 0.25.2 → 0.25.4

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,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.25.2";
4
+ const version = "0.25.4";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -720,13 +720,17 @@ function mergeShared(sharedOrArray) {
720
720
  function getEvent(event) {
721
721
  const silgi = useSilgi();
722
722
  if (silgi.options.present === "h3" || silgi.options.present === "nitro" || silgi.options.present === "nuxt") {
723
- return event.event;
723
+ return event;
724
724
  }
725
725
  return event;
726
726
  }
727
727
  function getEventContext(event) {
728
+ const silgi = useSilgi();
728
729
  const _event = getEvent(event);
729
- return _event.context;
730
+ if (silgi.options.present === "h3" || silgi.options.present === "nitro" || silgi.options.present === "nuxt") {
731
+ return _event.context;
732
+ }
733
+ return _event;
730
734
  }
731
735
 
732
736
  function createSchema(silgiType) {
@@ -3,6 +3,7 @@ import { ErrorFactory, HttpStatus, parseURI, silgi, SilgiError, useSilgi } from
3
3
  export async function addNitroApp(silgiCtx = useSilgi()) {
4
4
  const nitro = silgiCtx.framework;
5
5
  nitro.router.use("/srn/**", defineEventHandler(async (event) => {
6
+ let operation;
6
7
  try {
7
8
  const silgiConnect = silgi(event);
8
9
  const query = getQuery(event);
@@ -13,7 +14,7 @@ export async function addNitroApp(silgiCtx = useSilgi()) {
13
14
  } else {
14
15
  newPath = `${event.path}?method=${event.method}`;
15
16
  }
16
- const operation = parseURI(newPath, silgiCtx.uris);
17
+ operation = parseURI(newPath, silgiCtx.uris);
17
18
  if (!operation) {
18
19
  throw ErrorFactory.create({ message: "Invalid URI", httpStatus: HttpStatus.BAD_REQUEST });
19
20
  }
@@ -28,22 +29,33 @@ export async function addNitroApp(silgiCtx = useSilgi()) {
28
29
  if (data) {
29
30
  return data;
30
31
  }
31
- } catch (error) {
32
- if (error instanceof H3Error) {
33
- throw error;
32
+ } catch (err) {
33
+ if (err instanceof H3Error) {
34
+ throw err;
34
35
  }
35
- if (SilgiError.isError(error)) {
36
+ if (SilgiError.isError(err)) {
36
37
  throw createError({
37
- statusCode: error.httpStatus,
38
- message: error.message,
38
+ statusCode: err.httpStatus,
39
+ message: err.message,
39
40
  data: {
40
- code: error.code,
41
- category: error.category,
42
- severity: error.severity,
43
- context: error.context
41
+ code: err.code,
42
+ category: err.category,
43
+ severity: err.severity,
44
+ context: err.context
44
45
  }
45
46
  });
46
47
  }
48
+ await silgiCtx.callHook("execute:error", {
49
+ error: err instanceof Error ? err : new Error(String(err)),
50
+ timestamp: Date.now(),
51
+ operation,
52
+ event
53
+ });
54
+ silgiCtx.captureError(SilgiError.from(err), {
55
+ event,
56
+ operation,
57
+ tags: ["execute"]
58
+ });
47
59
  throw createError({
48
60
  statusCode: 500,
49
61
  message: "Internal Server Error"
@@ -486,7 +486,7 @@ type ModuleHookContext = Readonly<{
486
486
  error?: Error;
487
487
  success?: boolean;
488
488
  cached?: boolean;
489
- config: {
489
+ config?: {
490
490
  returnNull: boolean;
491
491
  };
492
492
  }>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.25.2",
4
+ "version": "0.25.4",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {