Skip to content

Commit

Permalink
Merge pull request #2 from Eliav2/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Eliav2 authored Apr 27, 2024
2 parents ecb820d + 16eaab1 commit 2dc34fe
Show file tree
Hide file tree
Showing 35 changed files with 502 additions and 183 deletions.
3 changes: 3 additions & 0 deletions .stackblitzrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"startCommand": "pnpm start-demo"
}
25 changes: 0 additions & 25 deletions demo/frontend-demo/src/App.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {TypedRouter} from "express-typed"
import express, { Request, Response } from "express";
import express from "express";
import logger from "morgan";
import typedRouter from "./routes/index.routes";

Expand All @@ -12,12 +11,6 @@ app.use(logger("dev"));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());

// const router = express.Router();

// router.get("/", async (req: Request, res: Response) => {
// res.send("Hello World!").status(200);
// });

app.use("/", typedRouter.router);

const server = app.listen(4000, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export type RoutesWithMethod<Method extends HandlerMethods> = {
// usage
// get all routes that have a "get" method, and their response types
type GetRoutes = RoutesWithMethod<"get">;
// ^?
// ^? type GetRoutes = { "/": "Hello world"};
// get all routes that have a "post" method, and their response types
type PostRoutes = RoutesWithMethod<"post">;
// ^?
////
////
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
14 changes: 14 additions & 0 deletions examples/fullstack_react_express-typed/frontend-demo/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "./App.css";
import { useAppQuery } from "./queries";

function App() {
const query = useAppQuery("/", "get");
const data = query.data;
// ^? const query: UseQueryResult<"Hello world", Error>

console.log("data", data);

return <>{JSON.stringify(data)}</>;
}

export default App;
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "express-demo",
"name": "regular-express",
"version": "1.0.0",
"type": "module",
"scripts": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"skipLibCheck": true,
"strict": true
},
"include": ["src/**/*.ts"],
"include": ["backend/src/**/*.ts"],
"exclude": ["node_modules"]
}
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "vitest --typecheck"
"test": "vitest --typecheck",
"start-demo": "pnpm --parallel --filter express-typed --filter \"./examples/fullstack_react_express-typed/*\" dev"
},
"dependencies": {
"express-typed": "workspace:*"
Expand All @@ -18,8 +19,13 @@
},
"devDependencies": {
"@vitest/ui": "^1.5.2",
"concurrently": "^8.2.2",
"typescript": "^5.4.5",
"vite": "^5.2.0",
"vitest": "^1.5.2"
},
"engines": {
"node": ">=20",
"pnpm": ">=9"
}
}
2 changes: 1 addition & 1 deletion packages/express-typed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"types": "dist/express-typed.d.ts",
"scripts": {
"build": "tsc",
"build:watch": "tsc -w",
"dev": "tsc -w",
"prepublish": "pnpm build",
"test": "vitest"
},
Expand Down
Loading

0 comments on commit 2dc34fe

Please sign in to comment.