@batijs/cli 0.0.25 → 0.0.27
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/README.md +3 -3
- package/dist/boilerplates/@batijs/edgedb/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/edgedb/{package-NAEM3YOJ.js → package-MC7EAK66.js} +4 -4
- package/dist/boilerplates/@batijs/express/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/express/files/express-entry.ts +124 -124
- package/dist/boilerplates/@batijs/express/{package-VWSKNQQS.js → package-PUCXLRMN.js} +4 -4
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +88 -88
- package/dist/boilerplates/@batijs/hattip/{package-PAHNC63I.js → package-WBQQVSZU.js} +4 -4
- package/dist/boilerplates/@batijs/prisma/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/prisma/{package-42T5MPMS.js → package-MYVHPWDR.js} +3 -3
- package/dist/boilerplates/@batijs/react/files/$package.json.js +12 -0
- package/dist/boilerplates/@batijs/react/files/$tsconfig.json.js +12 -0
- package/dist/boilerplates/@batijs/react/files/$vite.config.ts.js +17 -0
- package/dist/boilerplates/@batijs/react/files/assets/logo.svg +36 -0
- package/dist/boilerplates/@batijs/react/files/components/Link.tsx +15 -0
- package/dist/boilerplates/@batijs/react/files/layouts/HeadDefault.tsx +22 -0
- package/dist/boilerplates/@batijs/react/files/layouts/LayoutDefault.tsx +87 -0
- package/dist/boilerplates/@batijs/react/files/layouts/style.css +29 -0
- package/dist/boilerplates/@batijs/react/files/pages/+config.h.ts +18 -0
- package/dist/boilerplates/@batijs/react/files/pages/_error/+Page.tsx +22 -0
- package/dist/boilerplates/@batijs/react/files/pages/index/+Page.tsx +22 -0
- package/dist/boilerplates/@batijs/react/files/pages/index/Counter.tsx +18 -0
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/@id/+Page.tsx +17 -0
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/@id/+onBeforeRender.ts +27 -0
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/filterMovieData.ts +11 -0
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/index/+Page.tsx +22 -0
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/index/+onBeforeRender.ts +80 -0
- package/dist/boilerplates/@batijs/react/files/pages/star-wars/types.ts +13 -0
- package/dist/boilerplates/@batijs/react/package-L3XWD3PG.js +70 -0
- package/dist/boilerplates/@batijs/shared/files/package.json +2 -2
- package/dist/boilerplates/@batijs/shared/files/tsconfig.json +18 -18
- package/dist/boilerplates/@batijs/shared/files/vite.config.ts +5 -5
- package/dist/boilerplates/@batijs/solid/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/solid/files/assets/logo.svg +36 -36
- package/dist/boilerplates/@batijs/solid/files/components/Link.tsx +14 -14
- package/dist/boilerplates/@batijs/solid/files/layouts/HeadDefault.tsx +22 -22
- package/dist/boilerplates/@batijs/solid/files/layouts/LayoutDefault.tsx +87 -87
- package/dist/boilerplates/@batijs/solid/files/layouts/style.css +29 -29
- package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +13 -13
- package/dist/boilerplates/@batijs/solid/files/pages/_error/+Page.tsx +18 -18
- package/dist/boilerplates/@batijs/solid/files/pages/index/+Page.tsx +21 -21
- package/dist/boilerplates/@batijs/solid/files/pages/index/Counter.tsx +18 -18
- package/dist/boilerplates/@batijs/solid/files/pages/star-wars/@id/+Page.tsx +14 -14
- package/dist/boilerplates/@batijs/solid/files/pages/star-wars/@id/+onBeforeRender.ts +27 -27
- package/dist/boilerplates/@batijs/solid/files/pages/star-wars/filterMovieData.ts +11 -11
- package/dist/boilerplates/@batijs/solid/files/pages/star-wars/index/+Page.tsx +22 -22
- package/dist/boilerplates/@batijs/solid/files/pages/star-wars/index/+onBeforeRender.ts +80 -80
- package/dist/boilerplates/@batijs/solid/files/pages/star-wars/types.ts +13 -13
- package/dist/boilerplates/@batijs/solid/{package-DVZ6BETH.js → package-MRKOMCUY.js} +2 -2
- package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/tailwindcss/files/layouts/tailwind.css +2 -2
- package/dist/boilerplates/@batijs/tailwindcss/files/postcss.config.js +6 -6
- package/dist/boilerplates/@batijs/tailwindcss/files/tailwind.config.js +8 -8
- package/dist/boilerplates/@batijs/tailwindcss/{package-7CSFX2AA.js → package-42PZAQG7.js} +2 -2
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/telefunc/{package-42IE3DIX.js → package-CWDTGB4Z.js} +3 -3
- package/dist/boilerplates/boilerplates.json +12 -0
- package/dist/index.js +4 -4
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# @batijs/cli
|
|
2
|
-
|
|
3
|
-
WIP
|
|
1
|
+
# @batijs/cli
|
|
2
|
+
|
|
3
|
+
WIP
|
|
@@ -4,7 +4,7 @@ async function getPackageJson(currentContent) {
|
|
|
4
4
|
const packageJson = await loadAsJson(currentContent);
|
|
5
5
|
packageJson.scripts["edgedb:generate-queries"] = "@edgedb/generate queries";
|
|
6
6
|
packageJson.scripts["edgedb:generate-edgeql-js"] = "@edgedb/generate edgeql-js";
|
|
7
|
-
return addDependency(packageJson, await import("../package-
|
|
7
|
+
return addDependency(packageJson, await import("../package-MC7EAK66.js"), {
|
|
8
8
|
devDependencies: ["@edgedb/generate"],
|
|
9
9
|
dependencies: ["edgedb"]
|
|
10
10
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var name = "@batijs/edgedb";
|
|
3
3
|
var private2 = true;
|
|
4
|
-
var version = "0.0.
|
|
4
|
+
var version = "0.0.27";
|
|
5
5
|
var description = "";
|
|
6
6
|
var type = "module";
|
|
7
7
|
var scripts = {
|
|
@@ -12,11 +12,11 @@ var author = "";
|
|
|
12
12
|
var license = "MIT";
|
|
13
13
|
var devDependencies = {
|
|
14
14
|
"@batijs/tsup": "workspace:*",
|
|
15
|
-
"@edgedb/generate": "^0.2.
|
|
16
|
-
"@prisma/client": "^4.
|
|
15
|
+
"@edgedb/generate": "^0.2.1",
|
|
16
|
+
"@prisma/client": "^4.16.1",
|
|
17
17
|
"@types/node": "^16.18.36",
|
|
18
18
|
colorette: "^2.0.20",
|
|
19
|
-
edgedb: "^1.3.
|
|
19
|
+
edgedb: "^1.3.2",
|
|
20
20
|
tsup: "^6.7.0"
|
|
21
21
|
};
|
|
22
22
|
var dependencies = {
|
|
@@ -4,7 +4,7 @@ async function getPackageJson(currentContent, meta) {
|
|
|
4
4
|
const packageJson = await loadAsJson(currentContent);
|
|
5
5
|
packageJson.scripts.dev = "tsx ./express-entry.ts";
|
|
6
6
|
packageJson.scripts.build = "vite build";
|
|
7
|
-
return addDependency(packageJson, await import("../package-
|
|
7
|
+
return addDependency(packageJson, await import("../package-PUCXLRMN.js"), {
|
|
8
8
|
devDependencies: ["@types/express"],
|
|
9
9
|
dependencies: [
|
|
10
10
|
"@hattip/adapter-node",
|
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import { renderPage } from "vite-plugin-ssr/server";
|
|
2
|
-
import { telefunc } from "telefunc";
|
|
3
|
-
import { VikeAuth } from "vike-authjs";
|
|
4
|
-
import CredentialsProvider from "@auth/core/providers/credentials";
|
|
5
|
-
import express from "express";
|
|
6
|
-
import { createMiddleware } from "@hattip/adapter-node";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
import { dirname } from "node:path/posix";
|
|
9
|
-
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
-
const __dirname = dirname(__filename);
|
|
12
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
13
|
-
const root = __dirname;
|
|
14
|
-
|
|
15
|
-
startServer();
|
|
16
|
-
|
|
17
|
-
async function startServer() {
|
|
18
|
-
const app = express();
|
|
19
|
-
|
|
20
|
-
if (isProduction) {
|
|
21
|
-
app.use(express.static(`${root}/dist/client`));
|
|
22
|
-
} else {
|
|
23
|
-
// Instantiate Vite's development server and integrate its middleware to our server.
|
|
24
|
-
// ⚠️ We should instantiate it *only* in development. (It isn't needed in production
|
|
25
|
-
// and would unnecessarily bloat our server in production.)
|
|
26
|
-
const vite = await import("vite");
|
|
27
|
-
const viteDevMiddleware = (
|
|
28
|
-
await vite.createServer({
|
|
29
|
-
root,
|
|
30
|
-
server: { middlewareMode: true },
|
|
31
|
-
})
|
|
32
|
-
).middlewares;
|
|
33
|
-
app.use(viteDevMiddleware);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (import.meta.BATI_MODULES?.includes("auth:authjs")) {
|
|
37
|
-
/**
|
|
38
|
-
* AuthJS
|
|
39
|
-
*
|
|
40
|
-
* TODO: Replace secret {@see https://authjs.dev/reference/core#secret}
|
|
41
|
-
* TODO: Choose and implement providers
|
|
42
|
-
*
|
|
43
|
-
* @link {@see https://authjs.dev/guides/providers/custom-provider}
|
|
44
|
-
**/
|
|
45
|
-
const Auth = VikeAuth({
|
|
46
|
-
secret: "MY_SECRET",
|
|
47
|
-
providers: [
|
|
48
|
-
CredentialsProvider({
|
|
49
|
-
name: "Credentials",
|
|
50
|
-
credentials: {
|
|
51
|
-
username: { label: "Username", type: "text", placeholder: "jsmith" },
|
|
52
|
-
password: { label: "Password", type: "password" },
|
|
53
|
-
},
|
|
54
|
-
async authorize(credentials, req) {
|
|
55
|
-
// Add logic here to look up the user from the credentials supplied
|
|
56
|
-
const user = { id: "1", name: "J Smith", email: "jsmith@example.com" };
|
|
57
|
-
|
|
58
|
-
// Any object returned will be saved in `user` property of the JWT
|
|
59
|
-
// If you return null then an error will be displayed advising the user to check their details.
|
|
60
|
-
// You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter
|
|
61
|
-
return user ?? null;
|
|
62
|
-
},
|
|
63
|
-
}),
|
|
64
|
-
],
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
app.all(
|
|
68
|
-
"/api/auth/*",
|
|
69
|
-
createMiddleware(Auth, {
|
|
70
|
-
alwaysCallNext: false,
|
|
71
|
-
})
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (import.meta.BATI_MODULES?.includes("rpc:telefunc")) {
|
|
76
|
-
/**
|
|
77
|
-
* Telefunc route
|
|
78
|
-
*
|
|
79
|
-
* @link {@see https://telefunc.com}
|
|
80
|
-
**/
|
|
81
|
-
app.post(
|
|
82
|
-
"/_telefunc",
|
|
83
|
-
createMiddleware(
|
|
84
|
-
async (context) => {
|
|
85
|
-
const httpResponse = await telefunc({
|
|
86
|
-
url: context.request.url.toString(),
|
|
87
|
-
method: context.request.method,
|
|
88
|
-
body: await context.request.text(),
|
|
89
|
-
context,
|
|
90
|
-
});
|
|
91
|
-
const { body, statusCode, contentType } = httpResponse;
|
|
92
|
-
return new Response(body, {
|
|
93
|
-
status: statusCode,
|
|
94
|
-
headers: {
|
|
95
|
-
"content-type": contentType,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
alwaysCallNext: false,
|
|
101
|
-
}
|
|
102
|
-
)
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Vike route
|
|
108
|
-
*
|
|
109
|
-
* @link {@see https://vite-plugin-ssr.com}
|
|
110
|
-
**/
|
|
111
|
-
app.all("*", async (req, res, next) => {
|
|
112
|
-
const pageContextInit = { urlOriginal: req.originalUrl };
|
|
113
|
-
const pageContext = await renderPage(pageContextInit);
|
|
114
|
-
if (pageContext.httpResponse === null) return next();
|
|
115
|
-
|
|
116
|
-
const { statusCode, contentType } = pageContext.httpResponse;
|
|
117
|
-
res.status(statusCode).type(contentType);
|
|
118
|
-
pageContext.httpResponse.pipe(res);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
app.listen(process.env.PORT ? parseInt(process.env.PORT) : 3000, "localhost", () => {
|
|
122
|
-
console.log("Server listening on http://localhost:3000");
|
|
123
|
-
});
|
|
124
|
-
}
|
|
1
|
+
import { renderPage } from "vite-plugin-ssr/server";
|
|
2
|
+
import { telefunc } from "telefunc";
|
|
3
|
+
import { VikeAuth } from "vike-authjs";
|
|
4
|
+
import CredentialsProvider from "@auth/core/providers/credentials";
|
|
5
|
+
import express from "express";
|
|
6
|
+
import { createMiddleware } from "@hattip/adapter-node";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { dirname } from "node:path/posix";
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = dirname(__filename);
|
|
12
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
13
|
+
const root = __dirname;
|
|
14
|
+
|
|
15
|
+
startServer();
|
|
16
|
+
|
|
17
|
+
async function startServer() {
|
|
18
|
+
const app = express();
|
|
19
|
+
|
|
20
|
+
if (isProduction) {
|
|
21
|
+
app.use(express.static(`${root}/dist/client`));
|
|
22
|
+
} else {
|
|
23
|
+
// Instantiate Vite's development server and integrate its middleware to our server.
|
|
24
|
+
// ⚠️ We should instantiate it *only* in development. (It isn't needed in production
|
|
25
|
+
// and would unnecessarily bloat our server in production.)
|
|
26
|
+
const vite = await import("vite");
|
|
27
|
+
const viteDevMiddleware = (
|
|
28
|
+
await vite.createServer({
|
|
29
|
+
root,
|
|
30
|
+
server: { middlewareMode: true },
|
|
31
|
+
})
|
|
32
|
+
).middlewares;
|
|
33
|
+
app.use(viteDevMiddleware);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (import.meta.BATI_MODULES?.includes("auth:authjs")) {
|
|
37
|
+
/**
|
|
38
|
+
* AuthJS
|
|
39
|
+
*
|
|
40
|
+
* TODO: Replace secret {@see https://authjs.dev/reference/core#secret}
|
|
41
|
+
* TODO: Choose and implement providers
|
|
42
|
+
*
|
|
43
|
+
* @link {@see https://authjs.dev/guides/providers/custom-provider}
|
|
44
|
+
**/
|
|
45
|
+
const Auth = VikeAuth({
|
|
46
|
+
secret: "MY_SECRET",
|
|
47
|
+
providers: [
|
|
48
|
+
CredentialsProvider({
|
|
49
|
+
name: "Credentials",
|
|
50
|
+
credentials: {
|
|
51
|
+
username: { label: "Username", type: "text", placeholder: "jsmith" },
|
|
52
|
+
password: { label: "Password", type: "password" },
|
|
53
|
+
},
|
|
54
|
+
async authorize(credentials, req) {
|
|
55
|
+
// Add logic here to look up the user from the credentials supplied
|
|
56
|
+
const user = { id: "1", name: "J Smith", email: "jsmith@example.com" };
|
|
57
|
+
|
|
58
|
+
// Any object returned will be saved in `user` property of the JWT
|
|
59
|
+
// If you return null then an error will be displayed advising the user to check their details.
|
|
60
|
+
// You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter
|
|
61
|
+
return user ?? null;
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
app.all(
|
|
68
|
+
"/api/auth/*",
|
|
69
|
+
createMiddleware(Auth, {
|
|
70
|
+
alwaysCallNext: false,
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (import.meta.BATI_MODULES?.includes("rpc:telefunc")) {
|
|
76
|
+
/**
|
|
77
|
+
* Telefunc route
|
|
78
|
+
*
|
|
79
|
+
* @link {@see https://telefunc.com}
|
|
80
|
+
**/
|
|
81
|
+
app.post(
|
|
82
|
+
"/_telefunc",
|
|
83
|
+
createMiddleware(
|
|
84
|
+
async (context) => {
|
|
85
|
+
const httpResponse = await telefunc({
|
|
86
|
+
url: context.request.url.toString(),
|
|
87
|
+
method: context.request.method,
|
|
88
|
+
body: await context.request.text(),
|
|
89
|
+
context,
|
|
90
|
+
});
|
|
91
|
+
const { body, statusCode, contentType } = httpResponse;
|
|
92
|
+
return new Response(body, {
|
|
93
|
+
status: statusCode,
|
|
94
|
+
headers: {
|
|
95
|
+
"content-type": contentType,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
alwaysCallNext: false,
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Vike route
|
|
108
|
+
*
|
|
109
|
+
* @link {@see https://vite-plugin-ssr.com}
|
|
110
|
+
**/
|
|
111
|
+
app.all("*", async (req, res, next) => {
|
|
112
|
+
const pageContextInit = { urlOriginal: req.originalUrl };
|
|
113
|
+
const pageContext = await renderPage(pageContextInit);
|
|
114
|
+
if (pageContext.httpResponse === null) return next();
|
|
115
|
+
|
|
116
|
+
const { statusCode, contentType } = pageContext.httpResponse;
|
|
117
|
+
res.status(statusCode).type(contentType);
|
|
118
|
+
pageContext.httpResponse.pipe(res);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
app.listen(process.env.PORT ? parseInt(process.env.PORT) : 3000, "localhost", () => {
|
|
122
|
+
console.log("Server listening on http://localhost:3000");
|
|
123
|
+
});
|
|
124
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var name = "@batijs/express";
|
|
3
3
|
var private2 = true;
|
|
4
|
-
var version = "0.0.
|
|
4
|
+
var version = "0.0.27";
|
|
5
5
|
var description = "";
|
|
6
6
|
var type = "module";
|
|
7
7
|
var scripts = {
|
|
@@ -11,18 +11,18 @@ var keywords = [];
|
|
|
11
11
|
var author = "";
|
|
12
12
|
var license = "MIT";
|
|
13
13
|
var devDependencies = {
|
|
14
|
-
"@auth/core": "^0.8.
|
|
14
|
+
"@auth/core": "^0.8.4",
|
|
15
15
|
"@batijs/tsup": "workspace:*",
|
|
16
16
|
"@hattip/adapter-node": "^0.0.34",
|
|
17
17
|
"@types/express": "^4.17.17",
|
|
18
18
|
"@types/node": "^16.18.36",
|
|
19
19
|
express: "^4.18.2",
|
|
20
|
-
telefunc: "^0.1.
|
|
20
|
+
telefunc: "^0.1.57",
|
|
21
21
|
tsup: "^6.7.0",
|
|
22
22
|
tsx: "^3.12.7",
|
|
23
23
|
"vike-authjs": "^0.0.2",
|
|
24
24
|
vite: "^4.3.9",
|
|
25
|
-
"vite-plugin-ssr": "^0.4.
|
|
25
|
+
"vite-plugin-ssr": "^0.4.132"
|
|
26
26
|
};
|
|
27
27
|
var dependencies = {
|
|
28
28
|
"@batijs/core": "workspace:*"
|
|
@@ -7,7 +7,7 @@ async function getPackageJson(currentContent, meta) {
|
|
|
7
7
|
if (packageJson.scripts.preview) {
|
|
8
8
|
delete packageJson.scripts.preview;
|
|
9
9
|
}
|
|
10
|
-
return addDependency(packageJson, await import("../package-
|
|
10
|
+
return addDependency(packageJson, await import("../package-WBQQVSZU.js"), {
|
|
11
11
|
devDependencies: ["@hattip/vite", "@hattip/adapter-node"],
|
|
12
12
|
dependencies: [
|
|
13
13
|
"@hattip/router",
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { createRouter } from "@hattip/router";
|
|
2
|
-
import { renderPage } from "vite-plugin-ssr/server";
|
|
3
|
-
import { telefunc } from "telefunc";
|
|
4
|
-
import { VikeAuth } from "vike-authjs";
|
|
5
|
-
import CredentialsProvider from "@auth/core/providers/credentials";
|
|
6
|
-
|
|
7
|
-
const router = createRouter();
|
|
8
|
-
|
|
9
|
-
if (import.meta.BATI_MODULES?.includes("rpc:telefunc")) {
|
|
10
|
-
/**
|
|
11
|
-
* Telefunc route
|
|
12
|
-
*
|
|
13
|
-
* @link {@see https://telefunc.com}
|
|
14
|
-
**/
|
|
15
|
-
router.post("/_telefunc", async (context) => {
|
|
16
|
-
const httpResponse = await telefunc({
|
|
17
|
-
url: context.url.toString(),
|
|
18
|
-
method: context.method,
|
|
19
|
-
body: await context.request.text(),
|
|
20
|
-
context,
|
|
21
|
-
});
|
|
22
|
-
const { body, statusCode, contentType } = httpResponse;
|
|
23
|
-
return new Response(body, {
|
|
24
|
-
status: statusCode,
|
|
25
|
-
headers: {
|
|
26
|
-
"content-type": contentType,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (import.meta.BATI_MODULES?.includes("auth:authjs")) {
|
|
33
|
-
/**
|
|
34
|
-
* AuthJS
|
|
35
|
-
*
|
|
36
|
-
* TODO: Replace secret {@see https://authjs.dev/reference/core#secret}
|
|
37
|
-
* TODO: Choose and implement providers
|
|
38
|
-
*
|
|
39
|
-
* @link {@see https://authjs.dev/guides/providers/custom-provider}
|
|
40
|
-
**/
|
|
41
|
-
const Auth = VikeAuth({
|
|
42
|
-
secret: "MY_SECRET", // See
|
|
43
|
-
|
|
44
|
-
providers: [
|
|
45
|
-
CredentialsProvider({
|
|
46
|
-
name: "Credentials",
|
|
47
|
-
credentials: {
|
|
48
|
-
username: { label: "Username", type: "text", placeholder: "username" },
|
|
49
|
-
password: { label: "Password", type: "password" },
|
|
50
|
-
},
|
|
51
|
-
async authorize(credentials, req) {
|
|
52
|
-
// Add logic here to look up the user from the credentials supplied
|
|
53
|
-
const user = { id: "1", name: "J Smith", email: "jsmith@example.com" };
|
|
54
|
-
|
|
55
|
-
// Any object returned will be saved in `user` property of the JWT
|
|
56
|
-
// If you return null then an error will be displayed advising the user to check their details.
|
|
57
|
-
// You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter
|
|
58
|
-
return user ?? null;
|
|
59
|
-
},
|
|
60
|
-
}),
|
|
61
|
-
],
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
router.get("/api/auth/*", Auth);
|
|
65
|
-
router.post("/api/auth/*", Auth);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Vike route
|
|
70
|
-
*
|
|
71
|
-
* @link {@see https://vite-plugin-ssr.com}
|
|
72
|
-
**/
|
|
73
|
-
router.use(async (context) => {
|
|
74
|
-
const pageContextInit = { urlOriginal: context.request.url };
|
|
75
|
-
const pageContext = await renderPage(pageContextInit);
|
|
76
|
-
const response = pageContext.httpResponse;
|
|
77
|
-
|
|
78
|
-
return new Response(await response?.getBody(), {
|
|
79
|
-
status: response?.statusCode,
|
|
80
|
-
headers: response
|
|
81
|
-
? {
|
|
82
|
-
"content-type": response.contentType,
|
|
83
|
-
}
|
|
84
|
-
: {},
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
export default router.buildHandler();
|
|
1
|
+
import { createRouter } from "@hattip/router";
|
|
2
|
+
import { renderPage } from "vite-plugin-ssr/server";
|
|
3
|
+
import { telefunc } from "telefunc";
|
|
4
|
+
import { VikeAuth } from "vike-authjs";
|
|
5
|
+
import CredentialsProvider from "@auth/core/providers/credentials";
|
|
6
|
+
|
|
7
|
+
const router = createRouter();
|
|
8
|
+
|
|
9
|
+
if (import.meta.BATI_MODULES?.includes("rpc:telefunc")) {
|
|
10
|
+
/**
|
|
11
|
+
* Telefunc route
|
|
12
|
+
*
|
|
13
|
+
* @link {@see https://telefunc.com}
|
|
14
|
+
**/
|
|
15
|
+
router.post("/_telefunc", async (context) => {
|
|
16
|
+
const httpResponse = await telefunc({
|
|
17
|
+
url: context.url.toString(),
|
|
18
|
+
method: context.method,
|
|
19
|
+
body: await context.request.text(),
|
|
20
|
+
context,
|
|
21
|
+
});
|
|
22
|
+
const { body, statusCode, contentType } = httpResponse;
|
|
23
|
+
return new Response(body, {
|
|
24
|
+
status: statusCode,
|
|
25
|
+
headers: {
|
|
26
|
+
"content-type": contentType,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (import.meta.BATI_MODULES?.includes("auth:authjs")) {
|
|
33
|
+
/**
|
|
34
|
+
* AuthJS
|
|
35
|
+
*
|
|
36
|
+
* TODO: Replace secret {@see https://authjs.dev/reference/core#secret}
|
|
37
|
+
* TODO: Choose and implement providers
|
|
38
|
+
*
|
|
39
|
+
* @link {@see https://authjs.dev/guides/providers/custom-provider}
|
|
40
|
+
**/
|
|
41
|
+
const Auth = VikeAuth({
|
|
42
|
+
secret: "MY_SECRET", // See
|
|
43
|
+
|
|
44
|
+
providers: [
|
|
45
|
+
CredentialsProvider({
|
|
46
|
+
name: "Credentials",
|
|
47
|
+
credentials: {
|
|
48
|
+
username: { label: "Username", type: "text", placeholder: "username" },
|
|
49
|
+
password: { label: "Password", type: "password" },
|
|
50
|
+
},
|
|
51
|
+
async authorize(credentials, req) {
|
|
52
|
+
// Add logic here to look up the user from the credentials supplied
|
|
53
|
+
const user = { id: "1", name: "J Smith", email: "jsmith@example.com" };
|
|
54
|
+
|
|
55
|
+
// Any object returned will be saved in `user` property of the JWT
|
|
56
|
+
// If you return null then an error will be displayed advising the user to check their details.
|
|
57
|
+
// You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter
|
|
58
|
+
return user ?? null;
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
router.get("/api/auth/*", Auth);
|
|
65
|
+
router.post("/api/auth/*", Auth);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Vike route
|
|
70
|
+
*
|
|
71
|
+
* @link {@see https://vite-plugin-ssr.com}
|
|
72
|
+
**/
|
|
73
|
+
router.use(async (context) => {
|
|
74
|
+
const pageContextInit = { urlOriginal: context.request.url };
|
|
75
|
+
const pageContext = await renderPage(pageContextInit);
|
|
76
|
+
const response = pageContext.httpResponse;
|
|
77
|
+
|
|
78
|
+
return new Response(await response?.getBody(), {
|
|
79
|
+
status: response?.statusCode,
|
|
80
|
+
headers: response
|
|
81
|
+
? {
|
|
82
|
+
"content-type": response.contentType,
|
|
83
|
+
}
|
|
84
|
+
: {},
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export default router.buildHandler();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var name = "@batijs/hattip";
|
|
3
3
|
var private2 = true;
|
|
4
|
-
var version = "0.0.
|
|
4
|
+
var version = "0.0.27";
|
|
5
5
|
var description = "";
|
|
6
6
|
var type = "module";
|
|
7
7
|
var scripts = {
|
|
@@ -11,18 +11,18 @@ var keywords = [];
|
|
|
11
11
|
var author = "";
|
|
12
12
|
var license = "MIT";
|
|
13
13
|
var devDependencies = {
|
|
14
|
-
"@auth/core": "^0.8.
|
|
14
|
+
"@auth/core": "^0.8.4",
|
|
15
15
|
"@batijs/tsup": "workspace:*",
|
|
16
16
|
"@hattip/adapter-node": "^0.0.34",
|
|
17
17
|
"@hattip/router": "^0.0.34",
|
|
18
18
|
"@hattip/vite": "^0.0.34",
|
|
19
19
|
"@types/node": "^16.18.36",
|
|
20
20
|
hattip: "^0.0.33",
|
|
21
|
-
telefunc: "^0.1.
|
|
21
|
+
telefunc: "^0.1.57",
|
|
22
22
|
tsup: "^6.7.0",
|
|
23
23
|
"vike-authjs": "^0.0.2",
|
|
24
24
|
vite: "^4.3.9",
|
|
25
|
-
"vite-plugin-ssr": "^0.4.
|
|
25
|
+
"vite-plugin-ssr": "^0.4.132"
|
|
26
26
|
};
|
|
27
27
|
var dependencies = {
|
|
28
28
|
"@batijs/core": "workspace:*"
|
|
@@ -4,7 +4,7 @@ async function getPackageJson(currentContent) {
|
|
|
4
4
|
const packageJson = await loadAsJson(currentContent);
|
|
5
5
|
packageJson.scripts["prisma:studio"] = "prisma studio";
|
|
6
6
|
packageJson.scripts["prisma:generate"] = "prisma generate";
|
|
7
|
-
return addDependency(packageJson, await import("../package-
|
|
7
|
+
return addDependency(packageJson, await import("../package-MYVHPWDR.js"), {
|
|
8
8
|
devDependencies: ["prisma"],
|
|
9
9
|
dependencies: ["@prisma/client"]
|
|
10
10
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var name = "@batijs/prisma";
|
|
3
3
|
var private2 = true;
|
|
4
|
-
var version = "0.0.
|
|
4
|
+
var version = "0.0.27";
|
|
5
5
|
var description = "";
|
|
6
6
|
var type = "module";
|
|
7
7
|
var scripts = {
|
|
@@ -12,10 +12,10 @@ var author = "";
|
|
|
12
12
|
var license = "MIT";
|
|
13
13
|
var devDependencies = {
|
|
14
14
|
"@batijs/tsup": "workspace:*",
|
|
15
|
-
"@prisma/client": "^4.
|
|
15
|
+
"@prisma/client": "^4.16.1",
|
|
16
16
|
"@types/node": "^16.18.36",
|
|
17
17
|
colorette: "^2.0.20",
|
|
18
|
-
prisma: "^4.
|
|
18
|
+
prisma: "^4.16.1",
|
|
19
19
|
tsup: "^6.7.0"
|
|
20
20
|
};
|
|
21
21
|
var dependencies = {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// files/$package.json.ts
|
|
2
|
+
import { addDependency, loadAsJson } from "@batijs/core";
|
|
3
|
+
async function getPackageJson(currentContent) {
|
|
4
|
+
const packageJson = await loadAsJson(currentContent);
|
|
5
|
+
return addDependency(packageJson, await import("../package-L3XWD3PG.js"), {
|
|
6
|
+
devDependencies: ["vite"],
|
|
7
|
+
dependencies: ["@vitejs/plugin-react", "cross-fetch", "react", "react-dom", "vite-plugin-ssr", "vike-react"]
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
getPackageJson as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// files/$tsconfig.json.ts
|
|
2
|
+
import { loadAsJson } from "@batijs/core";
|
|
3
|
+
async function getTsConfig(currentContent) {
|
|
4
|
+
const tsConfig = await loadAsJson(currentContent);
|
|
5
|
+
tsConfig.compilerOptions.jsx = "preserve";
|
|
6
|
+
tsConfig.compilerOptions.jsxImportSource = "react";
|
|
7
|
+
tsConfig.compilerOptions.types = [...tsConfig.compilerOptions.types ?? [], "vike-react/client"];
|
|
8
|
+
return tsConfig;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
getTsConfig as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// files/$vite.config.ts.ts
|
|
2
|
+
import { addVitePlugin, loadAsMagicast } from "@batijs/core";
|
|
3
|
+
async function getViteConfig(currentContent) {
|
|
4
|
+
const mod = await loadAsMagicast(currentContent);
|
|
5
|
+
addVitePlugin(mod, {
|
|
6
|
+
from: "@vitejs/plugin-react",
|
|
7
|
+
constructor: "react"
|
|
8
|
+
});
|
|
9
|
+
addVitePlugin(mod, {
|
|
10
|
+
from: "vite-plugin-ssr/plugin",
|
|
11
|
+
constructor: "ssr"
|
|
12
|
+
});
|
|
13
|
+
return mod.generate().code;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
getViteConfig as default
|
|
17
|
+
};
|