@leo-h/create-nodejs-app 1.0.37 → 1.0.38
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 +1 -1
- package/templates/react-vite/.env.development +8 -0
- package/templates/react-vite/.env.example +4 -4
- package/templates/react-vite/api/errors.ts +14 -0
- package/templates/react-vite/{src/api → api}/swr-fetcher.ts +11 -10
- package/templates/react-vite/eslint.config.js +1 -1
- package/templates/react-vite/gitignore +4 -0
- package/templates/react-vite/orval.config.ts +5 -13
- package/templates/react-vite/package.json +23 -24
- package/templates/react-vite/pnpm-lock.yaml +566 -516
- package/templates/react-vite/scripts/orval-generate-api-definition.ts +2 -19
- package/templates/react-vite/src/app.tsx +1 -9
- package/templates/react-vite/src/pages/_layouts/app.tsx +7 -5
- package/templates/react-vite/src/pages/_layouts/auth.tsx +7 -5
- package/templates/react-vite/src/pages/app/dashboard/dashboard.tsx +2 -1
- package/templates/react-vite/src/pages/auth/sign-in/index.tsx +4 -2
- package/templates/react-vite/src/private-env.ts +18 -0
- package/templates/react-vite/src/public-env.ts +30 -0
- package/templates/react-vite/src/routes.tsx +29 -45
- package/templates/react-vite/tsconfig.app.json +3 -2
- package/templates/react-vite/tsconfig.json +2 -1
- package/templates/react-vite/tsconfig.node.json +8 -2
- package/templates/react-vite/vite.config.ts +1 -1
- package/templates/react-vite/src/api/errors/api-error.ts +0 -7
- package/templates/react-vite/src/api/errors/api-unexpected-response-error.ts +0 -8
- package/templates/react-vite/src/env.ts +0 -19
- package/templates/react-vite/src/hooks/use-current-route-handle-params.ts +0 -16
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@leo-h/create-nodejs-app",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.38",
|
4
4
|
"packageManager": "pnpm@9.15.9",
|
5
5
|
"author": "Leonardo Henrique <leonardo0507.business@gmail.com>",
|
6
6
|
"description": "Create a modern Node.js app with TypeScript using one command.",
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# example: "app-name"
|
2
|
-
|
2
|
+
PUBLIC_APP_NAME=
|
3
3
|
|
4
4
|
# example: "http://localhost:3333"
|
5
|
-
|
5
|
+
PUBLIC_API_BASE_URL=
|
6
6
|
|
7
|
-
# example: "http://localhost:3333/
|
8
|
-
API_JSON_DOCS_URL=
|
7
|
+
# example: "http://localhost:3333/json"
|
8
|
+
API_JSON_DOCS_URL=
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export class ApiError {
|
2
|
+
public constructor(
|
3
|
+
public readonly statusCode: number,
|
4
|
+
public readonly error: string,
|
5
|
+
public readonly message: string,
|
6
|
+
) {}
|
7
|
+
}
|
8
|
+
|
9
|
+
export class ApiUnexpectedResponseError {
|
10
|
+
static readonly message =
|
11
|
+
"Houve uma falha inesperada ao se comunicar com nosso servidor. Aguarde alguns instantes ou contate nosso suporte.";
|
12
|
+
|
13
|
+
constructor(public message = ApiUnexpectedResponseError.message) {}
|
14
|
+
}
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
import { ApiError } from "./errors
|
3
|
-
import { ApiUnexpectedResponseError } from "./errors/api-unexpected-response-error";
|
1
|
+
import { publicEnv } from "@/public-env";
|
2
|
+
import { ApiError, ApiUnexpectedResponseError } from "./errors";
|
4
3
|
|
5
4
|
type SwrFetcherOutput = {
|
6
5
|
body: unknown;
|
@@ -9,14 +8,16 @@ type SwrFetcherOutput = {
|
|
9
8
|
};
|
10
9
|
|
11
10
|
export async function swrFetcher<Output extends SwrFetcherOutput>(
|
12
|
-
|
13
|
-
options
|
11
|
+
endpointUrl: RequestInfo | URL,
|
12
|
+
options: RequestInit,
|
14
13
|
): Promise<Output> {
|
15
|
-
const
|
16
|
-
const endpointUrl = new URL(url.toString());
|
14
|
+
const url = new URL(publicEnv.API_BASE_URL);
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
if (url.pathname.endsWith("/")) {
|
17
|
+
url.pathname = endpointUrl.toString();
|
18
|
+
} else {
|
19
|
+
url.pathname += endpointUrl;
|
20
|
+
}
|
20
21
|
|
21
22
|
const response = await fetch(endpointUrl, options);
|
22
23
|
let body: unknown;
|
@@ -28,7 +29,7 @@ export async function swrFetcher<Output extends SwrFetcherOutput>(
|
|
28
29
|
try {
|
29
30
|
body = await response.json();
|
30
31
|
} catch {
|
31
|
-
body =
|
32
|
+
body = null;
|
32
33
|
}
|
33
34
|
}
|
34
35
|
|
@@ -3,14 +3,14 @@ import { OrvalCustomConfig } from "./scripts/orval-generate-api-definition";
|
|
3
3
|
|
4
4
|
export const orvalCustomConfig: OrvalCustomConfig = {
|
5
5
|
apiDocs: {
|
6
|
-
outputPath: "./
|
6
|
+
outputPath: "./api/docs.json",
|
7
7
|
},
|
8
8
|
endpoints: {
|
9
|
-
outputPath: "./
|
10
|
-
replaceVoidTypeToAnyOnResponse:
|
9
|
+
outputPath: "./api/orval/endpoints",
|
10
|
+
replaceVoidTypeToAnyOnResponse: false,
|
11
11
|
},
|
12
12
|
zodSchemas: {
|
13
|
-
outputPath: "./
|
13
|
+
outputPath: "./api/orval/schemas",
|
14
14
|
},
|
15
15
|
};
|
16
16
|
|
@@ -21,21 +21,13 @@ export default defineConfig({
|
|
21
21
|
target: orvalCustomConfig.endpoints.outputPath,
|
22
22
|
client: "swr",
|
23
23
|
httpClient: "fetch",
|
24
|
-
baseUrl: new URL(process.env.APP_API_BASE_URL!).toString(),
|
25
24
|
mode: "tags",
|
26
25
|
clean: true,
|
27
26
|
override: {
|
28
27
|
mutator: {
|
29
|
-
path: "./
|
28
|
+
path: "./api/swr-fetcher.ts",
|
30
29
|
name: "swrFetcher",
|
31
30
|
},
|
32
|
-
swr: {
|
33
|
-
swrOptions: {
|
34
|
-
errorRetryCount: 3,
|
35
|
-
errorRetryInterval: 3500,
|
36
|
-
revalidateOnFocus: false,
|
37
|
-
},
|
38
|
-
},
|
39
31
|
},
|
40
32
|
},
|
41
33
|
},
|
@@ -12,39 +12,38 @@
|
|
12
12
|
"format": "prettier . --write --cache",
|
13
13
|
"build": "tsc -b && vite build",
|
14
14
|
"preview": "vite preview",
|
15
|
-
"orval:generate": "tsx --env-file=.env ./scripts/orval-generate-api-definition.ts"
|
15
|
+
"orval:generate": "tsx --env-file=.env.development ./scripts/orval-generate-api-definition.ts"
|
16
16
|
},
|
17
17
|
"dependencies": {
|
18
|
-
"@hookform/resolvers": "
|
19
|
-
"i18next": "
|
20
|
-
"react": "
|
21
|
-
"react-dom": "
|
22
|
-
"react-
|
23
|
-
"react-
|
24
|
-
"react-router": "7.4.1",
|
18
|
+
"@hookform/resolvers": "5.0.1",
|
19
|
+
"i18next": "25.0.2",
|
20
|
+
"react": "19.1.0",
|
21
|
+
"react-dom": "19.1.0",
|
22
|
+
"react-hook-form": "7.56.1",
|
23
|
+
"react-router": "7.5.3",
|
25
24
|
"swr": "2.3.3",
|
26
|
-
"zod": "3.24.
|
25
|
+
"zod": "3.24.3",
|
27
26
|
"zod-i18n-map": "2.27.0"
|
28
27
|
},
|
29
28
|
"devDependencies": {
|
30
|
-
"@eslint/js": "9.
|
31
|
-
"@types/react": "
|
32
|
-
"@types/react-dom": "
|
33
|
-
"@vitejs/plugin-react": "4.
|
34
|
-
"eslint": "9.
|
35
|
-
"eslint-config-prettier": "
|
29
|
+
"@eslint/js": "9.25.1",
|
30
|
+
"@types/react": "19.1.2",
|
31
|
+
"@types/react-dom": "19.1.2",
|
32
|
+
"@vitejs/plugin-react": "4.4.1",
|
33
|
+
"eslint": "9.25.1",
|
34
|
+
"eslint-config-prettier": "10.1.2",
|
36
35
|
"eslint-plugin-react-hooks": "5.2.0",
|
37
|
-
"eslint-plugin-react-refresh": "0.4.
|
38
|
-
"globals": "
|
36
|
+
"eslint-plugin-react-refresh": "0.4.20",
|
37
|
+
"globals": "16.0.0",
|
39
38
|
"husky": "9.1.7",
|
40
|
-
"lint-staged": "15.5.
|
41
|
-
"orval": "7.
|
39
|
+
"lint-staged": "15.5.1",
|
40
|
+
"orval": "7.9.0",
|
42
41
|
"prettier": "3.5.3",
|
43
|
-
"tsx": "4.19.
|
44
|
-
"type-fest": "4.
|
45
|
-
"typescript": "~5.8.
|
46
|
-
"typescript-eslint": "8.
|
47
|
-
"vite": "6.
|
42
|
+
"tsx": "4.19.4",
|
43
|
+
"type-fest": "4.40.1",
|
44
|
+
"typescript": "~5.8.3",
|
45
|
+
"typescript-eslint": "8.31.1",
|
46
|
+
"vite": "6.3.3",
|
48
47
|
"vite-tsconfig-paths": "5.1.4"
|
49
48
|
}
|
50
49
|
}
|