silgi 0.16.2 → 0.16.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,4 +1,4 @@
1
- const version = "0.16.2";
1
+ const version = "0.16.4";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -206,8 +206,8 @@ const parseRouteRules = serviceParseModule(({
206
206
  const routeRules = node.routeRules;
207
207
  if (!routeRules)
208
208
  return;
209
- let removeMethod = basePath.split("/").slice(0, -1).join("/");
210
- removeMethod = withLeadingSlash(removeMethod);
209
+ let removeMethod = "";
210
+ removeMethod = withLeadingSlash(basePath);
211
211
  if (routeRules.splat)
212
212
  removeMethod = `${removeMethod}/*`;
213
213
  else if (routeRules.doubleSplat)
@@ -1,4 +1,4 @@
1
- const version = "0.16.2";
1
+ const version = "0.16.4";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,4 +1,4 @@
1
- const version = "0.16.2";
1
+ const version = "0.16.4";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,5 +1,5 @@
1
1
  import { createError, defineEventHandler, getQuery, H3Error, readBody } from "h3";
2
- import { silgi, SilgiError, useSilgi } from "silgi/core";
2
+ import { ErrorFactory, HttpStatus, parseURI, silgi, SilgiError, useSilgi } from "silgi/core";
3
3
  export default async function addNitroApp(silgiCtx = useSilgi()) {
4
4
  const nitro = silgiCtx.framework;
5
5
  nitro.router.use("/srn/**", defineEventHandler(async (event) => {
@@ -13,9 +13,14 @@ export default async function addNitroApp(silgiCtx = useSilgi()) {
13
13
  } else {
14
14
  newPath = `${event.path}?method=${event.method}`;
15
15
  }
16
+ const operation = parseURI(newPath, silgiCtx.uris);
17
+ if (!operation) {
18
+ throw ErrorFactory.create({ message: "Invalid URI", httpStatus: HttpStatus.BAD_REQUEST });
19
+ }
16
20
  await silgiCtx.callHook("event:init", event, {
17
21
  path: newPath,
18
- queryParams: query
22
+ queryParams: query,
23
+ operation
19
24
  });
20
25
  const data = await silgiConnect.execute(newPath, {
21
26
  ...body
@@ -1043,6 +1043,7 @@ interface SilgiRuntimeHooks {
1043
1043
  'event:init': (event: SilgiEvents, data: {
1044
1044
  path: string;
1045
1045
  queryParams?: Record<string, string>;
1046
+ operation: SilgiOperation;
1046
1047
  }) => HookResult;
1047
1048
  'error': CaptureError;
1048
1049
  }
@@ -1043,6 +1043,7 @@ interface SilgiRuntimeHooks {
1043
1043
  'event:init': (event: SilgiEvents, data: {
1044
1044
  path: string;
1045
1045
  queryParams?: Record<string, string>;
1046
+ operation: SilgiOperation;
1046
1047
  }) => HookResult;
1047
1048
  'error': CaptureError;
1048
1049
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.16.2",
4
+ "version": "0.16.4",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {