Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid authored Jun 17, 2024
2 parents 3ca9484 + ac3c504 commit 91d4ca6
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 67 deletions.
43 changes: 0 additions & 43 deletions .github/workflows/doc-checks.yml

This file was deleted.

11 changes: 9 additions & 2 deletions .github/workflows/deploy-docs.yml → .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ on:
push:
branches:
- main
merge_group:
pull_request:
paths:
- "docs/**"
- "package.json"
- "pnpm-lock.yaml"

env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

jobs:
docs:
name: "📜 Deploy Docs"
name: "📜 Docs"

strategy:
fail-fast: false
Expand Down Expand Up @@ -41,6 +47,7 @@ jobs:
env:
TARGET: cloudflare_module

- run: npx wrangler deploy
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: npx wrangler deploy
env:
WRANGLER_LOG: debug
15 changes: 12 additions & 3 deletions examples/with-auth/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { action, cache, redirect } from "@solidjs/router";
import { db } from "./db";
import { getSession, login, logout as logoutSession, register, validatePassword, validateUsername } from "./server";
import {
getSession,
login,
logout as logoutSession,
register,
validatePassword,
validateUsername
} from "./server";

export const getUser = cache(async () => {
"use server";
Expand Down Expand Up @@ -30,7 +37,9 @@ export const loginOrRegister = action(async (formData: FormData) => {
? register(username, password)
: login(username, password));
const session = await getSession();
await session.update(d => (d.userId = user!.id));
await session.update(d => {
d.userId = user.id;
});
} catch (err) {
return err as Error;
}
Expand All @@ -41,4 +50,4 @@ export const logout = action(async () => {
"use server";
await logoutSession();
return redirect("/login");
});
});
4 changes: 3 additions & 1 deletion examples/with-auth/src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export async function login(username: string, password: string) {

export async function logout() {
const session = await getSession();
await session.update(d => (d.userId = undefined));
await session.update(d => {
d.userId = undefined;
});
}

export async function register(username: string, password: string) {
Expand Down
21 changes: 7 additions & 14 deletions examples/with-drizzle/src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,14 @@ async function login(username: string, password: string) {
}

async function register(username: string, password: string) {
const existingUser = db
.select()
.from(Users)
.where(eq(Users.username, username))
.get();
const existingUser = db.select().from(Users).where(eq(Users.username, username)).get();
if (existingUser) throw new Error("User already exists");
return db
.insert(Users)
.values({ username, password })
.returning()
.get();
return db.insert(Users).values({ username, password }).returning().get();
}

function getSession() {
return useSession({
password:
process.env.SESSION_SECRET ?? "areallylongsecretthatyoushouldreplace",
password: process.env.SESSION_SECRET ?? "areallylongsecretthatyoushouldreplace"
});
}

Expand All @@ -56,7 +47,9 @@ export async function loginOrRegister(formData: FormData) {
? register(username, password)
: login(username, password));
const session = await getSession();
await session.update(d => (d.userId = user!.id));
await session.update(d => {
d.userId = user.id;
});
} catch (err) {
return err as Error;
}
Expand All @@ -65,7 +58,7 @@ export async function loginOrRegister(formData: FormData) {

export async function logout() {
const session = await getSession();
await session.update((d) => (d.userId = undefined));
await session.update(d => (d.userId = undefined));
throw redirect("/login");
}

Expand Down
15 changes: 12 additions & 3 deletions examples/with-prisma/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { action, cache, redirect } from "@solidjs/router";
import { db } from "./db";
import { getSession, login, logout as logoutSession, register, validatePassword, validateUsername } from "./server";
import {
getSession,
login,
logout as logoutSession,
register,
validatePassword,
validateUsername
} from "./server";

export const getUser = cache(async () => {
"use server";
Expand Down Expand Up @@ -30,7 +37,9 @@ export const loginOrRegister = action(async (formData: FormData) => {
? register(username, password)
: login(username, password));
const session = await getSession();
await session.update(d => (d.userId = user!.id));
await session.update(d => {
d.userId = user.id;
});
} catch (err) {
return err as Error;
}
Expand All @@ -41,4 +50,4 @@ export const logout = action(async () => {
"use server";
await logoutSession();
return redirect("/login");
});
});
4 changes: 3 additions & 1 deletion examples/with-prisma/src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export async function login(username: string, password: string) {

export async function logout() {
const session = await getSession();
await session.update(d => (d.userId = undefined));
await session.update(d => {
d.userId = undefined;
});
}

export async function register(username: string, password: string) {
Expand Down

0 comments on commit 91d4ca6

Please sign in to comment.