@stanlemon/app-template 0.3.54 → 0.3.56
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/package.json +6 -4
- package/src/App.test.tsx +1 -1
- package/src/Session.tsx +2 -2
- package/src/components/Column.tsx +2 -2
- package/src/components/Row.tsx +2 -2
- package/src/views/Account.test.tsx +1 -1
- package/src/views/Items.test.tsx +2 -2
- package/src/views/Login.tsx +4 -1
- package/src/views/Password.tsx +1 -1
- package/src/views/Profile.tsx +1 -1
- package/src/views/SignUp.tsx +1 -1
- package/src/views/Verify.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanlemon/app-template",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.56",
|
|
4
4
|
"description": "A template for creating apps using the webdev package.",
|
|
5
5
|
"author": "Stan Lemon <stanlemon@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"start:dev": "NODE_ENV=development nodemon --ignore ./db.json app.js",
|
|
12
12
|
"build": "npm run webpack:build",
|
|
13
13
|
"tsc": "tsc",
|
|
14
|
-
"webpack:serve": "webpack serve",
|
|
14
|
+
"webpack:serve": "NODE_ENV=development webpack serve",
|
|
15
15
|
"webpack:build": "NODE_ENV=production webpack",
|
|
16
16
|
"dev": "NODE_ENV=development concurrently \"npm run webpack:serve\" \"npm run start:dev\"",
|
|
17
17
|
"test": "jest --detectOpenHandles",
|
|
18
18
|
"test:watch": "jest -w",
|
|
19
19
|
"test:coverage": "jest --coverage",
|
|
20
|
-
"lint": "eslint
|
|
21
|
-
"lint:fix": "eslint --fix
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"lint:fix": "eslint --fix ."
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@stanlemon/server-with-auth": "*",
|
|
@@ -31,9 +31,11 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@testing-library/react": "^16.0.1",
|
|
33
33
|
"@testing-library/user-event": "^14.5.2",
|
|
34
|
+
"@types/jest": "^29.5.13",
|
|
34
35
|
"@types/react": "^18.3.8",
|
|
35
36
|
"@types/react-dom": "^18.3.0",
|
|
36
37
|
"concurrently": "^9.0.1",
|
|
38
|
+
"nodemon": "^3.1.7",
|
|
37
39
|
"supertest": "^7.0.0"
|
|
38
40
|
}
|
|
39
41
|
}
|
package/src/App.test.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { render, screen, waitFor } from "@testing-library/react";
|
|
|
3
3
|
import App from "./App";
|
|
4
4
|
import { ItemData } from "./views";
|
|
5
5
|
import { SessionAware } from "./Session";
|
|
6
|
-
import fetchApi from "./helpers/fetchApi";
|
|
6
|
+
import { fetchApi } from "./helpers/fetchApi";
|
|
7
7
|
|
|
8
8
|
jest.mock("./helpers/fetchApi");
|
|
9
9
|
|
package/src/Session.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect, useContext, createContext } from "react";
|
|
2
2
|
import { useCookies } from "react-cookie";
|
|
3
3
|
import { ErrorMessage } from "./components/";
|
|
4
|
-
import fetchApi from "./helpers/fetchApi";
|
|
4
|
+
import { fetchApi } from "./helpers/fetchApi";
|
|
5
5
|
|
|
6
6
|
type SessionContextProperties = {
|
|
7
7
|
initialized: boolean;
|
|
@@ -71,7 +71,7 @@ export function SessionLoader({ children }: { children: React.ReactNode }) {
|
|
|
71
71
|
fetchApi<SessionData, null>("/auth/session", token || cookies.session_token)
|
|
72
72
|
.then((session: SessionData) => {
|
|
73
73
|
if (session) {
|
|
74
|
-
setCookie("session_token", session.token
|
|
74
|
+
setCookie("session_token", session.token);
|
|
75
75
|
setToken(session.token);
|
|
76
76
|
setUser(session.user);
|
|
77
77
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { createElement } from "react";
|
|
2
2
|
|
|
3
3
|
export function Column({
|
|
4
4
|
as = "div",
|
|
@@ -7,7 +7,7 @@ export function Column({
|
|
|
7
7
|
as?: keyof React.JSX.IntrinsicElements;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
}) {
|
|
10
|
-
return
|
|
10
|
+
return createElement(
|
|
11
11
|
as,
|
|
12
12
|
{
|
|
13
13
|
style: {
|
package/src/components/Row.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { createElement } from "react";
|
|
2
2
|
|
|
3
3
|
export function Row({
|
|
4
4
|
as = "div",
|
|
@@ -7,7 +7,7 @@ export function Row({
|
|
|
7
7
|
as?: keyof React.JSX.IntrinsicElements;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
}) {
|
|
10
|
-
return
|
|
10
|
+
return createElement(
|
|
11
11
|
as,
|
|
12
12
|
{
|
|
13
13
|
style: {
|
|
@@ -3,7 +3,7 @@ import { render, screen, fireEvent, waitFor } from "@testing-library/react";
|
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import { Account, PasswordRequest, ProfileForm } from "./";
|
|
5
5
|
import { SessionAware } from "../Session";
|
|
6
|
-
import fetchApi from "../helpers/fetchApi";
|
|
6
|
+
import { fetchApi } from "../helpers/fetchApi";
|
|
7
7
|
|
|
8
8
|
jest.mock("../helpers/fetchApi");
|
|
9
9
|
|
package/src/views/Items.test.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@testing-library/jest-dom";
|
|
2
2
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import Items,
|
|
4
|
+
import { Items, ItemData } from "./Items";
|
|
5
5
|
import { SessionAware } from "../Session";
|
|
6
|
-
import fetchApi from "../helpers/fetchApi";
|
|
6
|
+
import { fetchApi } from "../helpers/fetchApi";
|
|
7
7
|
|
|
8
8
|
jest.mock("../helpers/fetchApi");
|
|
9
9
|
|
package/src/views/Login.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState, useContext } from "react";
|
|
2
|
+
import { useCookies } from "react-cookie";
|
|
2
3
|
import { Input, Spacer } from "../components/";
|
|
3
4
|
import { ProfileData, SessionContext, SessionData } from "../Session";
|
|
4
|
-
import fetchApi,
|
|
5
|
+
import { fetchApi, ApiError } from "../helpers/fetchApi";
|
|
5
6
|
|
|
6
7
|
export type LoginForm = {
|
|
7
8
|
username: string;
|
|
@@ -13,6 +14,7 @@ export function Login() {
|
|
|
13
14
|
username: "",
|
|
14
15
|
password: "",
|
|
15
16
|
});
|
|
17
|
+
const [_, setCookie] = useCookies(["session_token"]);
|
|
16
18
|
|
|
17
19
|
const { setToken, setUser, setError } = useContext(SessionContext);
|
|
18
20
|
|
|
@@ -22,6 +24,7 @@ export function Login() {
|
|
|
22
24
|
.then((session: SessionData) => {
|
|
23
25
|
setToken(session.token as string);
|
|
24
26
|
setUser(session.user as ProfileData);
|
|
27
|
+
setCookie("session_token", session.token);
|
|
25
28
|
setError(null);
|
|
26
29
|
})
|
|
27
30
|
.catch((err: ApiError) => {
|
package/src/views/Password.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext, useState } from "react";
|
|
2
2
|
import { SessionContext } from "../Session";
|
|
3
3
|
import { Header, Input } from "../components";
|
|
4
|
-
import fetchApi,
|
|
4
|
+
import { fetchApi, ApiError } from "../helpers/fetchApi";
|
|
5
5
|
|
|
6
6
|
export type PasswordForm = {
|
|
7
7
|
current_password: string;
|
package/src/views/Profile.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext, useState } from "react";
|
|
2
2
|
import { ProfileData, SessionContext } from "../Session";
|
|
3
3
|
import { Header, Input } from "../components";
|
|
4
|
-
import fetchApi,
|
|
4
|
+
import { fetchApi, ApiError } from "../helpers/fetchApi";
|
|
5
5
|
|
|
6
6
|
export type ProfileForm = {
|
|
7
7
|
name: string;
|
package/src/views/SignUp.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useContext } from "react";
|
|
2
2
|
import { Input, Spacer } from "../components/";
|
|
3
3
|
import { SessionContext, ProfileData, SessionData } from "../Session";
|
|
4
|
-
import fetchApi,
|
|
4
|
+
import { fetchApi, ApiError } from "../helpers/fetchApi";
|
|
5
5
|
|
|
6
6
|
export type FormErrors = {
|
|
7
7
|
errors: Record<string, string>;
|
package/src/views/Verify.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext, useEffect } from "react";
|
|
2
|
-
import fetchApi,
|
|
2
|
+
import { fetchApi, ApiError } from "../helpers/fetchApi";
|
|
3
3
|
import { SessionContext } from "../Session";
|
|
4
4
|
|
|
5
5
|
export function Verify({ token = null }: { token: string | null }) {
|