Skip to content

Commit c09af3d

Browse files
authored
feat: rename libs to adapters and implement route decorators with @guard support (#69)
* feat: rename libs to adapters and implement route decorators with @guard support - Refactor/Rename: Moved all runtime-specific library abstractions under `src/libs/` (e.g., fs, net, process, serde, task for Lune, Lute, and Zune) to `src/adapters/`. - Path Aliasing: Updated path resolutions in configuration files (`.luaurc`, test configurations, and runner scripts) to map the new `@adapters` alias. - Decorator System: - Created a parser and extractor in `src/core/decorator.luau` to parse decorator annotations (like `@Guard`) from route handlers. - Added `src/core/decoratorRegistry.luau` to manage and load custom decorators. - Implemented the `@Guard` decorator (`src/core/decorators/Guard.luau`) to conditionally allow or block requests (returning a `401 Unauthorized` response on failure). - Route Integration: Integrated decorator parsing and execution within `src/core/generateRoute.luau` using middleware chaining to wrap matched route handlers. - Tooling and Configuration: - Added `selene.toml` for Lua/Luau linting configurations. - Added `zunes.yml` configuration. - Testing: Added mock Auth guard and updated web tests to verify guard and decorator functionality. * fix: update aliases in .luaurc to use relative paths * chore: test * fix: update adapters alias in .luaurc to use relative path
1 parent 35ecbc1 commit c09af3d

57 files changed

Lines changed: 346 additions & 55 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.luaurc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
{
2-
"languageMode": "strict",
2+
"languageMode": "strict",
33
"globals": [
44
"warn"
5-
],
5+
],
66
"aliases": {
7-
"src": "./src/",
8-
"c": "/home/wiz/projects/nova-projects/nova/tests/web/",
9-
"lint": "~/.lute/typedefs/1.0.0/lint",
10-
"test-runner": "./tests/runner",
11-
"std": "~/.lute/typedefs/1.0.0/std",
12-
"lune": "~/.lune/.typedefs/0.10.4/",
7+
"adapters": "./src/adapters",
8+
"std": "~/.lute/typedefs/1.0.0/std",
9+
"c": "/home/wiz/projects/nova-projects/nova_core/tests/web/",
10+
"core": "@src/core",
11+
"src": "./src/",
12+
"lune": "~/.lune/.typedefs/0.10.4/",
13+
"test-runner": "./tests/runner",
14+
"utils": "./src/utils",
15+
"lint": "~/.lute/typedefs/1.0.0/lint",
1316
"lute": "~/.lute/typedefs/1.0.0/lute"
1417
}
1518
}

.lune/dev.luau

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local process = require("@lune/process")
2-
local serde = require("../src/libs/serde")
3-
local fs = require("../src/libs/fs")
2+
local serde = require("@adapters/serde")
3+
local fs = require("@adapters/fs")
44

55
local luaurcPath = process.cwd .. ".luaurc"
66
local luaurcjson = fs.readFile(luaurcPath)

.lune/start.luau

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local process = require("@lune/process")
2-
local serde = require("../src/libs/serde")
3-
local fs = require("../src/libs/fs")
2+
local serde = require("@adapters/serde")
3+
local fs = require("@adapters/fs")
44

55
local luaurcPath = process.cwd .. ".luaurc"
66
local luaurcjson = fs.readFile(luaurcPath)

.lune/test.luau

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
local process = require("@lune/process")
22

3-
process.exec("lune", { "run", "tests" }, { stdio = "inherit" })
3+
local child = process.exec("lune", { "run", "tests" }, { stdio = "inherit" })
4+
5+
if not child.ok then
6+
process.exit(child.code)
7+
end

.lute/dev.luau

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local process = require("@lute/process")
2-
local serde = require("../src/libs/serde")
3-
local fs = require("../src/libs/fs")
2+
local serde = require("@adapters/serde")
3+
local fs = require("@adapters/fs")
44

55
local luaurcPath = process.cwd() .. "/.luaurc"
66
local luaurcjson = fs.readFile(luaurcPath)

.lute/start.luau

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local process = require("@lute/process")
2-
local serde = require("../src/libs/serde")
3-
local fs = require("../src/libs/fs")
2+
local serde = require("@adapters/serde")
3+
local fs = require("@adapters/fs")
44

55
local luaurcPath = process.cwd() .. "/.luaurc"
66
local luaurcjson = fs.readFile(luaurcPath)

.lute/test.luau

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
local process = require("@lute/process")
22

3-
process.run({ "lute", "run", "tests" }, { stdio = "inherit" })
3+
local child = process.run({ "lute", "run", "tests" }, { stdio = "inherit" })
4+
5+
if not child.ok then
6+
process.exit(child.exitcode)
7+
end

.zune/dev.luau

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local process = zune.process
2-
local serde = require("../src/libs/serde")
3-
local fs = require("../src/libs/fs")
2+
local serde = require("@adapters/serde")
3+
local fs = require("@adapters/fs")
44

55
local luaurcPath = process.cwd() .. "/.luaurc"
66
local luaurcjson = fs.readFile(luaurcPath)

.zune/start.luau

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local process = zune.process
2-
local serde = require("../src/libs/serde")
3-
local fs = require("../src/libs/fs")
2+
local serde = require("@adapters/serde")
3+
local fs = require("@adapters/fs")
44

55
local luaurcPath = process.cwd() .. "/.luaurc"
66
local luaurcjson = fs.readFile(luaurcPath)

.zune/test.luau

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
local process = zune.process
22

3-
process.run("zune", { "run", "tests" }, { stdout = "inherit", stderr = "inherit" })
3+
local child = process.run("zune", { "run", "tests" }, { stdout = "inherit", stderr = "inherit" })
4+
5+
if not child.ok then
6+
process.exit(child.code)
7+
end

0 commit comments

Comments
 (0)