create-authenik8-app 1.0.0
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.
- package/dist/bin/index.d.ts +3 -0
- package/dist/bin/index.d.ts.map +1 -0
- package/dist/bin/index.js +110 -0
- package/dist/bin/index.js.map +1 -0
- package/package.json +25 -0
- package/templates/express-ts/prisma/schema.prisma +6 -0
- package/templates/express-ts/src/.env.example +3 -0
- package/templates/express-ts/src/package-lock.json +2427 -0
- package/templates/express-ts/src/package.json +19 -0
- package/templates/express-ts/src/server.ts +36 -0
- package/templates/express-ts/src/tsconfig.json +47 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "authenik8-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "ts-node-dev --respawn --transpile-only ./server.ts",
|
|
6
|
+
"build": "tsc",
|
|
7
|
+
"start": "node dist/server.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"authenik8-core": "^0.1.5",
|
|
11
|
+
"dotenv": "^16.0.0",
|
|
12
|
+
"express": "^4.18.2"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"ts-node-dev": "^2.0.0",
|
|
16
|
+
"typescript": "^5.0.0"
|
|
17
|
+
},
|
|
18
|
+
"type": "commonjs"
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { createAuthenik8 } from "authenik8-core";
|
|
3
|
+
|
|
4
|
+
const app = express();
|
|
5
|
+
app.use(express.json());
|
|
6
|
+
|
|
7
|
+
async function start() {
|
|
8
|
+
const auth = await createAuthenik8({
|
|
9
|
+
jwtSecret: process.env.JWT_SECRET!,
|
|
10
|
+
refreshSecret: process.env.REFRESH_SECRET!,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
app.post("/login", async (req, res) => {
|
|
14
|
+
const user = { id: "123", email: "test@test.com" };
|
|
15
|
+
|
|
16
|
+
const accessToken = auth.signToken(user);
|
|
17
|
+
const refreshToken = await auth.generateRefreshToken(user);
|
|
18
|
+
|
|
19
|
+
res.json({ accessToken, refreshToken });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
app.post("/refresh", async (req, res) => {
|
|
23
|
+
const tokens = await auth.refreshToken(req.body.refreshToken);
|
|
24
|
+
res.json(tokens);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
app.get("/protected", auth.requireAdmin, (req, res) => {
|
|
28
|
+
res.json({ message: "Protected route" });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
app.listen(3000, () => {
|
|
32
|
+
console.log("🚀 Server running on http://localhost:3000");
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
start();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "ES2020",
|
|
12
|
+
"types": [],
|
|
13
|
+
// For nodejs:
|
|
14
|
+
// "lib": ["esnext"],
|
|
15
|
+
// "types": ["node"],
|
|
16
|
+
// and npm install -D @types/node
|
|
17
|
+
|
|
18
|
+
// Other Outputs
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
|
|
23
|
+
// Stricter Typechecking Options
|
|
24
|
+
"noUncheckedIndexedAccess": true,
|
|
25
|
+
"exactOptionalPropertyTypes": true,
|
|
26
|
+
|
|
27
|
+
// Style Options
|
|
28
|
+
// "noImplicitReturns": true,
|
|
29
|
+
// "noImplicitOverride": true,
|
|
30
|
+
// "noUnusedLocals": true,
|
|
31
|
+
// "noUnusedParameters": true,
|
|
32
|
+
// "noFallthroughCasesInSwitch": true,
|
|
33
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
34
|
+
|
|
35
|
+
// Recommended Options
|
|
36
|
+
"strict": true,
|
|
37
|
+
"jsx": "react-jsx",
|
|
38
|
+
"verbatimModuleSyntax": true,
|
|
39
|
+
"isolatedModules": true,
|
|
40
|
+
"noUncheckedSideEffectImports": true,
|
|
41
|
+
"moduleDetection": "force",
|
|
42
|
+
"skipLibCheck": true,
|
|
43
|
+
"esModuleInterop":true,
|
|
44
|
+
//"moduleResolution":Nodenext,
|
|
45
|
+
},
|
|
46
|
+
"exclude":["dist"]
|
|
47
|
+
}
|