create-sprint 0.0.72 → 0.0.74
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,13 +1,19 @@
|
|
|
1
1
|
export function getInternalAuthMiddleware(language) {
|
|
2
2
|
if (language === "typescript") {
|
|
3
|
-
return `import {
|
|
3
|
+
return `import { z } from "sprint-es/schemas";
|
|
4
|
+
import { defineMiddleware, SprintRequest, SprintResponse, NextFunction } from "sprint-es";
|
|
4
5
|
|
|
5
6
|
export default defineMiddleware({
|
|
6
7
|
name: "adminAuth",
|
|
7
8
|
priority: 10,
|
|
8
9
|
include: "/admin/**",
|
|
10
|
+
schema: {
|
|
11
|
+
sprint: {
|
|
12
|
+
authorization: z.sprint().authorization()
|
|
13
|
+
}
|
|
14
|
+
},
|
|
9
15
|
handler: (req: SprintRequest, res: SprintResponse, next: NextFunction) => {
|
|
10
|
-
const auth = req.sprint.
|
|
16
|
+
const auth = req.sprint.authorization;
|
|
11
17
|
if (!auth) return res.status(401).json({ error: "No authorization header" });
|
|
12
18
|
|
|
13
19
|
const token = auth.replace("Bearer ", "");
|
|
@@ -19,14 +25,20 @@ export default defineMiddleware({
|
|
|
19
25
|
});
|
|
20
26
|
`;
|
|
21
27
|
}
|
|
22
|
-
return `import {
|
|
28
|
+
return `import { z } from "sprint-es/schemas";
|
|
29
|
+
import { defineMiddleware } from "sprint-es";
|
|
23
30
|
|
|
24
31
|
export default defineMiddleware({
|
|
25
32
|
name: "adminAuth",
|
|
26
33
|
priority: 10,
|
|
27
34
|
include: "/admin/**",
|
|
35
|
+
schema: {
|
|
36
|
+
sprint: {
|
|
37
|
+
authorization: z.sprint().authorization()
|
|
38
|
+
}
|
|
39
|
+
},
|
|
28
40
|
handler: (req, res, next) => {
|
|
29
|
-
const auth = req.sprint.
|
|
41
|
+
const auth = req.sprint.authorization;
|
|
30
42
|
if (!auth) return res.status(401).json({ error: "No authorization header" });
|
|
31
43
|
|
|
32
44
|
const token = auth.replace("Bearer ", "");
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
export function getInternalAuthMiddleware(language: string) {
|
|
2
2
|
if (language === "typescript") {
|
|
3
|
-
return `import {
|
|
3
|
+
return `import { z } from "sprint-es/schemas";
|
|
4
|
+
import { defineMiddleware, SprintRequest, SprintResponse, NextFunction } from "sprint-es";
|
|
4
5
|
|
|
5
6
|
export default defineMiddleware({
|
|
6
7
|
name: "adminAuth",
|
|
7
8
|
priority: 10,
|
|
8
9
|
include: "/admin/**",
|
|
10
|
+
schema: {
|
|
11
|
+
sprint: {
|
|
12
|
+
authorization: z.sprint().authorization()
|
|
13
|
+
}
|
|
14
|
+
},
|
|
9
15
|
handler: (req: SprintRequest, res: SprintResponse, next: NextFunction) => {
|
|
10
|
-
const auth = req.sprint.
|
|
16
|
+
const auth = req.sprint.authorization;
|
|
11
17
|
if (!auth) return res.status(401).json({ error: "No authorization header" });
|
|
12
18
|
|
|
13
19
|
const token = auth.replace("Bearer ", "");
|
|
@@ -19,14 +25,20 @@ export default defineMiddleware({
|
|
|
19
25
|
});
|
|
20
26
|
`;
|
|
21
27
|
}
|
|
22
|
-
return `import {
|
|
28
|
+
return `import { z } from "sprint-es/schemas";
|
|
29
|
+
import { defineMiddleware } from "sprint-es";
|
|
23
30
|
|
|
24
31
|
export default defineMiddleware({
|
|
25
32
|
name: "adminAuth",
|
|
26
33
|
priority: 10,
|
|
27
34
|
include: "/admin/**",
|
|
35
|
+
schema: {
|
|
36
|
+
sprint: {
|
|
37
|
+
authorization: z.sprint().authorization()
|
|
38
|
+
}
|
|
39
|
+
},
|
|
28
40
|
handler: (req, res, next) => {
|
|
29
|
-
const auth = req.sprint.
|
|
41
|
+
const auth = req.sprint.authorization;
|
|
30
42
|
if (!auth) return res.status(401).json({ error: "No authorization header" });
|
|
31
43
|
|
|
32
44
|
const token = auth.replace("Bearer ", "");
|