add api generator #172
4
pkgs/ui/.gitignore
vendored
4
pkgs/ui/.gitignore
vendored
@ -37,3 +37,7 @@ yarn-error.log*
|
|||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
|
||||||
|
# Generated api code
|
||||||
|
openapi.json
|
||||||
|
api/
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ floco ? builtins.getFlake "github:aakropotkin/floco"
|
{ floco ? builtins.getFlake "github:aakropotkin/floco"
|
||||||
, system ? builtins.currentSystem
|
, system ? builtins.currentSystem
|
||||||
, pkgs ? import <nixpkgs> { currentSystem = system; }
|
, pkgs ? import <nixpkgs> { currentSystem = system; }
|
||||||
|
, clanPkgs ? { }
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ let
|
|||||||
./nix/floco-cfg.nix
|
./nix/floco-cfg.nix
|
||||||
];
|
];
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit pkgs;
|
inherit pkgs clanPkgs;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
perSystem = { pkgs, system, ... }:
|
perSystem = { pkgs, system, ... }:
|
||||||
let
|
let
|
||||||
inherit (self.inputs) floco;
|
inherit (self.inputs) floco;
|
||||||
base = pkgs.callPackage ./default.nix { inherit floco system; };
|
base = pkgs.callPackage ./default.nix { inherit floco system; clanPkgs = self.packages.${system}; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
@ -12,6 +12,7 @@
|
|||||||
devShells.ui = pkgs.callPackage ./shell.nix {
|
devShells.ui = pkgs.callPackage ./shell.nix {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
inherit (base) fmod pkg;
|
inherit (base) fmod pkg;
|
||||||
|
clanPkgs = self.packages.${system};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "export",
|
output: "export",
|
||||||
images: { unoptimized: true },
|
images: { unoptimized: true },
|
||||||
|
eslint: {
|
||||||
|
dirs: ["src"],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ lib, config, pkgs, ... }:
|
{ lib, config, pkgs, clanPkgs, ... }:
|
||||||
let
|
let
|
||||||
|
|
||||||
pjs =
|
pjs =
|
||||||
@ -27,19 +27,27 @@ let
|
|||||||
"aarch64-darwin" = "@next/swc-darwin-arm64";
|
"aarch64-darwin" = "@next/swc-darwin-arm64";
|
||||||
}.${config.floco.settings.system};
|
}.${config.floco.settings.system};
|
||||||
|
|
||||||
# '
|
esbuildVersions = lib.filterAttrs (name: _attrs: name == "esbuild") config.floco.pdefs;
|
||||||
# "@next/swc-darwin-arm64": "13.4.12",
|
highestEsbuildVersion = lib.last (builtins.attrNames esbuildVersions.esbuild);
|
||||||
# "@next/swc-darwin-x64": "13.4.12",
|
|
||||||
|
|
||||||
# "@next/swc-linux-arm64-gnu": "13.4.12",
|
esbuildArch = {
|
||||||
# "@next/swc-linux-arm64-musl": "13.4.12",
|
# esbuild-linux-64
|
||||||
|
"x86_64-linux" = "esbuild-linux-64";
|
||||||
# "@next/swc-linux-x64-gnu": "13.4.12",
|
"x86_64-darwin" = "esbuild-darwin-64";
|
||||||
# "@next/swc-linux-x64-musl": "13.4.12",
|
"aarch64-darwin" = "esbuild-darwin-arm64";
|
||||||
|
}.${config.floco.settings.system};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
config.floco.packages.esbuild =
|
||||||
|
builtins.mapAttrs
|
||||||
|
(
|
||||||
|
version: _attrs: {
|
||||||
|
installed.override.copyTree = true;
|
||||||
|
installed.tree = config.floco.packages.${esbuildArch}.${version}.global;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
esbuildVersions.esbuild;
|
||||||
# ---------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------- #
|
||||||
|
|
||||||
config.floco.packages.${ident}.${version} =
|
config.floco.packages.${ident}.${version} =
|
||||||
@ -61,7 +69,13 @@ in
|
|||||||
# nextjs chaches some stuff in $HOME
|
# nextjs chaches some stuff in $HOME
|
||||||
built.override.preBuild = ''
|
built.override.preBuild = ''
|
||||||
export HOME=./home
|
export HOME=./home
|
||||||
ln -s ${pkgs.roboto}/share/fonts ./src/fonts
|
|
||||||
|
|
||||||
|
echo "----------- GENERATE API TS ------------"
|
||||||
|
cp ${clanPkgs.clan-openapi}/openapi.json .
|
||||||
|
./node_modules/.bin/orval
|
||||||
|
|
||||||
|
ln -fs ${pkgs.roboto}/share/fonts ./src/
|
||||||
|
|
||||||
echo "----------- RUNNING LINT ------------"
|
echo "----------- RUNNING LINT ------------"
|
||||||
next lint --max-warnings 0
|
next lint --max-warnings 0
|
||||||
@ -79,6 +93,12 @@ in
|
|||||||
optional = false;
|
optional = false;
|
||||||
dev = true;
|
dev = true;
|
||||||
};
|
};
|
||||||
|
"node_modules/${esbuildArch}" = {
|
||||||
|
key = "${esbuildArch}/${highestEsbuildVersion}";
|
||||||
|
link = false;
|
||||||
|
optional = false;
|
||||||
|
dev = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
|
File diff suppressed because it is too large
Load Diff
16
pkgs/ui/orval.config.ts
Normal file
16
pkgs/ui/orval.config.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
const config = {
|
||||||
|
petstore: {
|
||||||
|
output: {
|
||||||
|
mode: "tags-split",
|
||||||
|
target: "api",
|
||||||
|
schemas: "api/model",
|
||||||
|
client: "swr",
|
||||||
|
// mock: true,
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
target: "./openapi.json",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
2867
pkgs/ui/package-lock.json
generated
2867
pkgs/ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,7 @@
|
|||||||
"@mui/icons-material": "^5.14.3",
|
"@mui/icons-material": "^5.14.3",
|
||||||
"@mui/material": "^5.14.3",
|
"@mui/material": "^5.14.3",
|
||||||
"autoprefixer": "10.4.14",
|
"autoprefixer": "10.4.14",
|
||||||
|
"axios": "^1.4.0",
|
||||||
"classnames": "^2.3.2",
|
"classnames": "^2.3.2",
|
||||||
"hex-rgb": "^5.0.0",
|
"hex-rgb": "^5.0.0",
|
||||||
"next": "13.4.12",
|
"next": "13.4.12",
|
||||||
@ -26,6 +27,7 @@
|
|||||||
"react-hook-form": "^7.45.4",
|
"react-hook-form": "^7.45.4",
|
||||||
"react-hot-toast": "^2.4.1",
|
"react-hot-toast": "^2.4.1",
|
||||||
"recharts": "^2.7.3",
|
"recharts": "^2.7.3",
|
||||||
|
"swr": "^2.2.1",
|
||||||
"tailwindcss": "3.3.3"
|
"tailwindcss": "3.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -33,9 +35,11 @@
|
|||||||
"@types/react": "18.2.18",
|
"@types/react": "18.2.18",
|
||||||
"@types/react-dom": "18.2.7",
|
"@types/react-dom": "18.2.7",
|
||||||
"@types/w3c-web-usb": "^1.0.6",
|
"@types/w3c-web-usb": "^1.0.6",
|
||||||
"eslint": "8.46.0",
|
"esbuild": "^0.15.18",
|
||||||
|
"eslint": "^8.46.0",
|
||||||
"eslint-config-next": "13.4.12",
|
"eslint-config-next": "13.4.12",
|
||||||
"eslint-plugin-tailwindcss": "^3.13.0",
|
"eslint-plugin-tailwindcss": "^3.13.0",
|
||||||
|
"orval": "^6.17.0",
|
||||||
"prettier": "^3.0.1",
|
"prettier": "^3.0.1",
|
||||||
"prettier-plugin-tailwindcss": "^0.4.1",
|
"prettier-plugin-tailwindcss": "^0.4.1",
|
||||||
"typescript": "5.1.6"
|
"typescript": "5.1.6"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{ fmod
|
{ fmod
|
||||||
, pkg
|
, pkg
|
||||||
, pkgs
|
, pkgs
|
||||||
,
|
, clanPkgs
|
||||||
}:
|
}:
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
@ -19,8 +19,14 @@ pkgs.mkShell {
|
|||||||
echo "floco ok: node_modules updated"
|
echo "floco ok: node_modules updated"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sf ${pkgs.roboto}/share/fonts ./src/fonts
|
ln -sf ${pkgs.roboto}/share/fonts ./src
|
||||||
|
|
||||||
export PATH="$PATH:$(realpath ./node_modules)/.bin"
|
export PATH="$PATH:$(realpath ./node_modules)/.bin"
|
||||||
|
|
||||||
|
|
||||||
|
# re-generate the api code
|
||||||
|
rm -rf api openapi.json
|
||||||
|
cp ${clanPkgs.clan-openapi}/openapi.json .
|
||||||
|
orval
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import { Sidebar } from "@/components/sidebar";
|
|||||||
import MenuIcon from "@mui/icons-material/Menu";
|
import MenuIcon from "@mui/icons-material/Menu";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { tw } from "@/utils/tailwind";
|
import { tw } from "@/utils/tailwind";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
const roboto = localFont({
|
const roboto = localFont({
|
||||||
src: [
|
src: [
|
||||||
@ -30,6 +31,8 @@ const roboto = localFont({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
axios.defaults.baseURL = "http://localhost:2979";
|
||||||
|
|
||||||
// add negative margin for smooth transition to fill the space of the sidebar
|
// add negative margin for smooth transition to fill the space of the sidebar
|
||||||
const translate = tw`lg:-ml-64 -ml-14`;
|
const translate = tw`lg:-ml-64 -ml-14`;
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useListMachines } from "../../../../api/default/default";
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
return [{ id: "1" }, { id: "2" }];
|
return [{ id: "1" }, { id: "2" }];
|
||||||
@ -46,6 +47,8 @@ interface TemplateDetailProps {
|
|||||||
params: { id: string };
|
params: { id: string };
|
||||||
}
|
}
|
||||||
export default function TemplateDetail({ params }: TemplateDetailProps) {
|
export default function TemplateDetail({ params }: TemplateDetailProps) {
|
||||||
|
const { data, isLoading } = useListMachines();
|
||||||
|
console.log({ data, isLoading });
|
||||||
const details = getTemplate(params);
|
const details = getTemplate(params);
|
||||||
|
|
||||||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"]
|
"@/*": ["./src/*"],
|
||||||
|
"API": ["./api/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||||
|
Loading…
Reference in New Issue
Block a user