create-nevela 0.1.1 → 0.1.3

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,7 +1,7 @@
1
1
  "use server";
2
2
 
3
3
  import { cookies } from "next/headers";
4
- import { laravel, TOKEN_COOKIE } from "@/lib/laravel";
4
+ import { API_URL, laravel, TOKEN_COOKIE } from "@/lib/laravel";
5
5
 
6
6
  export type SignInResult = { ok: true } | { ok: false; error: string };
7
7
 
@@ -17,12 +17,20 @@ export async function signInAction(email: string, password: string): Promise<Sig
17
17
  try {
18
18
  response = await laravel("auth/token", { method: "POST", body: { email, password }, token: null });
19
19
  } catch {
20
- return { ok: false, error: "Can't reach the server. Check that the Laravel app is running." };
20
+ return { ok: false, error: `Can't reach the server at ${API_URL}. Start it with: php nevela dev` };
21
21
  }
22
22
  if (!response.ok) {
23
- const body = (response.body ?? {}) as { error?: string; issues?: { message: string }[] };
23
+ const body = (response.body ?? {}) as { error?: string; message?: string; issues?: { message: string }[] };
24
24
  if (response.status === 429) return { ok: false, error: "Too many attempts. Wait a minute and try again." };
25
- return { ok: false, error: body.issues?.[0]?.message ?? body.error ?? "Sign-in failed. Try again." };
25
+ if (response.status === 404 || response.status === 405) {
26
+ // Something answered, but it has no sign-in route: it isn't this app's API. Usually
27
+ // another program already had the port when the API was started.
28
+ return {
29
+ ok: false,
30
+ error: `${API_URL} is answered by a different program, not this app's API. Stop what is using that port, or start both with "php nevela dev", which picks a free one.`,
31
+ };
32
+ }
33
+ return { ok: false, error: body.issues?.[0]?.message ?? body.error ?? body.message ?? "Sign-in failed. Try again." };
26
34
  }
27
35
 
28
36
  const { token } = response.body as { token: string };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nevela-web",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {