Skip to content

Commit

Permalink
switch to typescript-fetch for api generation
Browse files Browse the repository at this point in the history
  • Loading branch information
acrantel committed Aug 19, 2023
1 parent 1e17ddf commit 74c270a
Show file tree
Hide file tree
Showing 137 changed files with 9,656 additions and 6,716 deletions.
5 changes: 4 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ repos:
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
exclude: ^frontend2/src/utils/types
- id: mixed-line-ending
args: ["--fix=lf"]
exclude: ^frontend2/src/utils/types
- id: trailing-whitespace
exclude: ^frontend2/src/utils/types

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
types_or: [css, html, javascript, json, jsx, markdown]
exclude: ^frontend/public/assets
exclude: ^frontend/public/assets | ^frontend2/src/utils/types

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
Expand Down
1 change: 0 additions & 1 deletion frontend2/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/node_modules
/.pnp
.pnp.js
/types

# production
/build
Expand Down
2 changes: 1 addition & 1 deletion frontend2/generate_types.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ python backend/manage.py spectacular --file schema.yml
:: npm install @openapitools/openapi-generator-cli -g
:: if you have a java error, just install java 8 and reload terminal
echo "Generate typescript types from schema"
npx @openapitools/openapi-generator-cli generate -i schema.yml -o frontend2/src/utils/types -g typescript-jquery --additional-properties=modelPropertyNaming=camelCase --additional-properties=disallowAdditionalPropertiesIfNotPresent=false
npx @openapitools/openapi-generator-cli generate -i schema.yml -o frontend2/src/utils/types -g typescript-fetch --additional-properties=modelPropertyNaming=original --additional-properties=disallowAdditionalPropertiesIfNotPresent=false --additional-properties=stringEnums=true
4 changes: 2 additions & 2 deletions frontend2/src/components/CurrentUserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CurrentUserContext,
} from "../contexts/CurrentUserContext";
import * as Api from "../utils/api";
import { removeApiTokens, doApiTokensExist } from "../utils/cookies";
import { removeApiTokens } from "../utils/cookies";

export const CurrentUserProvider: React.FC<{ children: React.ReactNode }> = ({
children,
Expand All @@ -33,7 +33,7 @@ export const CurrentUserProvider: React.FC<{ children: React.ReactNode }> = ({
useEffect(() => {
const checkLoggedIn = async (): Promise<void> => {
// check if cookies exist before attempting to load user
if (!doApiTokensExist()) {
if (!(await Api.verifyCurrentToken())) {
logout();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend2/src/contexts/CurrentUserContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext, useContext } from "react";
import { type UserPrivate } from "../utils/types/model/models";
import { type UserPrivate } from "../utils/types";

export enum AuthStateEnum {
LOADING = "loading",
Expand Down
Loading

0 comments on commit 74c270a

Please sign in to comment.