create-cfast 0.0.1
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/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/index.js +681 -0
- package/package.json +37 -0
- package/templates/admin/app/admin.server.ts +87 -0
- package/templates/admin/app/routes/admin.tsx +18 -0
- package/templates/admin/package.json +6 -0
- package/templates/auth/app/auth.client.ts +6 -0
- package/templates/auth/app/auth.helpers.server.ts +35 -0
- package/templates/auth/app/auth.setup.server.ts +17 -0
- package/templates/auth/app/db/schema.ts +106 -0
- package/templates/auth/app/routes/auth.$.tsx +10 -0
- package/templates/auth/app/routes/login.tsx +25 -0
- package/templates/auth/package.json +8 -0
- package/templates/base/_gitignore +14 -0
- package/templates/base/app/entry.server.tsx +38 -0
- package/templates/base/app/permissions.ts +32 -0
- package/templates/base/app/routes/_index.tsx +8 -0
- package/templates/base/package.json +32 -0
- package/templates/base/react-router.config.ts +8 -0
- package/templates/base/tsconfig.cloudflare.json +26 -0
- package/templates/base/tsconfig.json +14 -0
- package/templates/base/tsconfig.node.json +13 -0
- package/templates/base/workers/app.ts +29 -0
- package/templates/db/app/db/client.ts +8 -0
- package/templates/db/app/db/schema.ts +9 -0
- package/templates/db/drizzle.config.ts +7 -0
- package/templates/db/package.json +14 -0
- package/templates/email/app/email/send.ts +10 -0
- package/templates/email/app/email/templates/welcome.tsx +19 -0
- package/templates/email/app/email.server.ts +33 -0
- package/templates/email/package.json +6 -0
- package/templates/storage/package.json +5 -0
- package/templates/ui/app/actions.server.ts +12 -0
- package/templates/ui/app/components/Header.tsx +30 -0
- package/templates/ui/package.json +10 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createActions } from "@cfast/actions";
|
|
2
|
+
import { app } from "~/cfast.server";
|
|
3
|
+
|
|
4
|
+
export const { createAction, composeActions } = createActions({
|
|
5
|
+
getContext: async ({ request }) => {
|
|
6
|
+
const ctx = await app.context(request);
|
|
7
|
+
if (!ctx.auth.user) {
|
|
8
|
+
throw new Response(null, { status: 302, headers: { Location: "/login" } });
|
|
9
|
+
}
|
|
10
|
+
return { db: ctx.db.client, user: ctx.auth.user, grants: ctx.auth.grants };
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Link } from "react-router";
|
|
2
|
+
import Container from "@mui/joy/Container";
|
|
3
|
+
import Stack from "@mui/joy/Stack";
|
|
4
|
+
import Typography from "@mui/joy/Typography";
|
|
5
|
+
import Button from "@mui/joy/Button";
|
|
6
|
+
|
|
7
|
+
type HeaderProps = {
|
|
8
|
+
user?: { name: string } | null;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function Header({ user }: HeaderProps) {
|
|
12
|
+
return (
|
|
13
|
+
<Container sx={{ py: 2, borderBottom: "1px solid", borderColor: "divider" }}>
|
|
14
|
+
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
|
15
|
+
<Typography level="h4" component={Link} to="/" sx={{ textDecoration: "none" }}>
|
|
16
|
+
{{projectName}}
|
|
17
|
+
</Typography>
|
|
18
|
+
<Stack direction="row" spacing={1}>
|
|
19
|
+
{user ? (
|
|
20
|
+
<Typography level="body-sm">{user.name}</Typography>
|
|
21
|
+
) : (
|
|
22
|
+
<Button component={Link} to="/login" size="sm">
|
|
23
|
+
Sign In
|
|
24
|
+
</Button>
|
|
25
|
+
)}
|
|
26
|
+
</Stack>
|
|
27
|
+
</Stack>
|
|
28
|
+
</Container>
|
|
29
|
+
);
|
|
30
|
+
}
|