Skip to content

Commit

Permalink
test performance
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesthl committed Apr 1, 2024
1 parent 792ed31 commit 665ccee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
10 changes: 10 additions & 0 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import type { AppContext } from "./context";
import { AuthController } from "./controller/auth/auth.controller";
import { UserController } from "./controller/user/user.controller";
import { initalizeDB } from "./database/db";
import { users } from "./database/schema";

const app = new Hono<AppContext>();

app
.use(logger())
.get("/", (c) => {
return c.json({ message: "Hello World!" });
})
.use((c, next) => {
const handler = cors({ origin: c.env.WEB_DOMAIN });
return handler(c, next);
Expand All @@ -22,6 +26,12 @@ app
initializeLucia(c);
return next();
})
.get("/performance", async (c) => {
const now = new Date();
const users = await c.get("db").query.users.findMany();
console.log(`took ${new Date().getTime() - now.getTime()}ms to get users`);
return c.json({ users: users.length });
})
.use(AuthMiddleware);

const routes = app.route("/auth", AuthController).route("/user", UserController);
Expand Down
16 changes: 5 additions & 11 deletions apps/api/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ compatibility_date = "2023-12-04"

vars = { ENVIRONMENT = "development" }

[env.production]
vars = { ENVIRONMENT = "production" }

# [[kv_namespaces]]
# binding = "MY_KV_NAMESPACE"
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

# [[r2_buckets]]
# binding = "MY_BUCKET"
# bucket_name = "my-bucket"
[[d1_databases]]
binding = "DB" # i.e. available in your Worker on env.DB
database_name = "demo"
database_id = "b016f510-a7f5-4596-a596-836314b25841"
preview_database_id = "DB"
migrations_dir = "./src/database/migrations"
migrations_dir = "./src/database/migrations"

[env.production]
vars = { ENVIRONMENT = "production" }

6 changes: 5 additions & 1 deletion apps/expo/app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export default function AppLayout() {
const { loading, user } = useAuth();

if (loading) {
return <Text>Loading...</Text>;
return (
<>
<Text>Loading...</Text> <Stack.Screen options={{ headerShown: false }} />
</>
);
}

if (!user) {
Expand Down

0 comments on commit 665ccee

Please sign in to comment.