Skip to content

Commit dbc73bb

Browse files
authored
Merge pull request #9 from codebar/chore/add-fallow
chore: add fallow static analysis to CI
2 parents a6c3a6b + 09ddb50 commit dbc73bb

5 files changed

Lines changed: 160 additions & 23 deletions

File tree

.fallowrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json",
3+
"entry": ["test/features/*.test.js"],
4+
"ignoreDependencies": ["pino"],
5+
"ignoreExports": [{ "file": "static/auth-client.js", "exports": ["*"] }]
6+
}

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
- run: |
6969
npm run prettier:check
7070
npm run lint
71+
npm run fallow
7172
npm run db:generate
7273
npm run db:migrate
7374

package-lock.json

Lines changed: 130 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"dev": "node --watch src/index.js",
66
"db:generate": "npx @better-auth/cli generate --yes",
77
"db:migrate": "npx @better-auth/cli migrate --yes",
8+
"fallow": "fallow",
89
"prettier:check": "prettier --check '**/*.{js,css,md,yml}'",
910
"prettier:write": "prettier --write '**/*.{js,css,md,yml}'",
1011
"lint": "eslint .",
@@ -28,6 +29,7 @@
2829
"@commitlint/config-conventional": "^20.5.0",
2930
"@eslint/js": "^10.0.1",
3031
"eslint": "^10.2.0",
32+
"fallow": "^2.40.3",
3133
"globals": "^17.4.0",
3234
"prettier": "^3.8.1",
3335
"tap": "^21.6.3"

test/features/magic-links.test.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,31 @@ import { test } from "tap";
22
import { getTestInstance } from "../helpers/test-instance.js";
33
import { createApp } from "../../src/app/app.js";
44

5+
/**
6+
* Make a magic link request to the app
7+
* @param {Object} app - Hono app instance
8+
* @param {string} email - Email address for the magic link
9+
* @returns {Promise<Response>} The response from the request
10+
*/
11+
async function makeMagicLinkRequest(app, email) {
12+
const formData = new URLSearchParams();
13+
formData.append("email", email);
14+
15+
return app.request("/login/magic-link", {
16+
method: "POST",
17+
headers: {
18+
"Content-Type": "application/x-www-form-urlencoded",
19+
},
20+
body: formData.toString(),
21+
});
22+
}
23+
524
test("magic links feature tests", async (t) => {
625
t.test("user can request magic link", async (t) => {
726
const testInstance = await getTestInstance();
827
const app = createApp(testInstance.auth);
928

10-
const formData = new URLSearchParams();
11-
formData.append("email", "magic@example.com");
12-
13-
const res = await app.request("/login/magic-link", {
14-
method: "POST",
15-
headers: {
16-
"Content-Type": "application/x-www-form-urlencoded",
17-
},
18-
body: formData.toString(),
19-
});
29+
const res = await makeMagicLinkRequest(app, "magic@example.com");
2030

2131
t.equal(res.status, 302, "redirects after requesting magic link");
2232
t.match(
@@ -30,16 +40,7 @@ test("magic links feature tests", async (t) => {
3040
const testInstance = await getTestInstance();
3141
const app = createApp(testInstance.auth);
3242

33-
const formData = new URLSearchParams();
34-
formData.append("email", "nonexistent@example.com");
35-
36-
const res = await app.request("/login/magic-link", {
37-
method: "POST",
38-
headers: {
39-
"Content-Type": "application/x-www-form-urlencoded",
40-
},
41-
body: formData.toString(),
42-
});
43+
const res = await makeMagicLinkRequest(app, "nonexistent@example.com");
4344

4445
// Should still show success to prevent email enumeration
4546
t.equal(res.status, 302, "redirects after requesting magic link");

0 commit comments

Comments
 (0)