sveltekit-python-vercel 0.4.0 → 0.4.1

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.
@@ -2,7 +2,7 @@ import argparse
2
2
  import shutil
3
3
  import glob
4
4
 
5
- from pathlib import Path
5
+ from pathlib import Path, PurePosixPath
6
6
 
7
7
  parser = argparse.ArgumentParser(description="Run Sveltekit Python Deployment")
8
8
  parser.add_argument("--root", default=".", help="Root directory of Vercel project")
@@ -25,7 +25,12 @@ for module_path in glob.glob(str(root_dir / 'src/routes/**/+server.py'), recursi
25
25
 
26
26
  # replace the root_dir with api_dir
27
27
  api_route = api_dir / Path(module_path).absolute().relative_to(root_dir / "src/routes")
28
+
29
+ # replace square brackets with curly brackets
28
30
  api_route = Path(str(api_route).replace('[', '{').replace(']', '}'))
31
+
32
+ # remove any groups from the URL
33
+ api_route = Path(str(PurePosixPath(*[part for part in PurePosixPath(api_route).parts if not part.startswith("(") and not part.endswith(")")])))
29
34
 
30
35
  if not api_route.parent.exists():
31
36
  api_route.parent.mkdir(parents=True)
@@ -2,7 +2,7 @@ import glob
2
2
  import importlib
3
3
  import importlib.util
4
4
  import os
5
- from pathlib import Path
5
+ from pathlib import Path, PurePosixPath
6
6
 
7
7
  from fastapi import FastAPI, Request
8
8
  from fastapi.responses import JSONResponse
@@ -25,6 +25,9 @@ for module_path in glob.glob('./**/+server.py', recursive=True):
25
25
 
26
26
  # Replace square brackets with curly brackets
27
27
  api_route = api_route.replace('[', '{').replace(']', '}')
28
+
29
+ # remove any groups from the URL
30
+ api_route = str(PurePosixPath(*[part for part in PurePosixPath(api_route).parts if not part.startswith("(") and not part.endswith(")")]))
28
31
 
29
32
  mod = importlib.import_module(module_name, module_package)
30
33
 
@@ -3,7 +3,7 @@ import glob
3
3
  import importlib
4
4
  import importlib.util
5
5
  import shutil
6
- from pathlib import Path
6
+ from pathlib import Path, PurePosixPath
7
7
 
8
8
  import uvicorn
9
9
  from fastapi import FastAPI
@@ -53,6 +53,9 @@ for module_path in glob.glob(
53
53
 
54
54
  # Replace square brackets with curly brackets
55
55
  api_path = api_path.replace("[", "{").replace("]", "}")
56
+
57
+ # remove any groups from the URL
58
+ api_path = str(PurePosixPath(*[part for part in PurePosixPath(api_path).parts if not part.startswith("(") and not part.endswith(")")]))
56
59
 
57
60
  # Add endpoints
58
61
  for method in ["GET", "POST", "PATCH", "PUT", "DELETE"]:
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/mod.js",
3
3
  "types": "./types/mod.d.ts",
4
4
  "name": "sveltekit-python-vercel",
5
- "version": "v0.4.0",
5
+ "version": "v0.4.1",
6
6
  "description": "Write Sveltekit server endpoints in Python and seamlessly deploy to Vercel",
7
7
  "repository": {
8
8
  "type": "git",