Skip to content

chore: Update Hono and dependencies #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/mail-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@hono/node-server": "^1.11.1",
"@hono/trpc-server": "^0.2.0",
"@hono/trpc-server": "^0.3.1",
"@hono/zod-validator": "^0.2.1",
"@t3-oss/env-core": "^0.10.1",
"@trpc/client": "^10.45.2",
Expand All @@ -27,7 +27,7 @@
"@u22n/tsconfig": "^0.0.2",
"@u22n/utils": "workspace:*",
"drizzle-orm": "^0.30.3",
"hono": "^4.3.6",
"hono": "^4.3.7",
"mailauth": "^4.6.5",
"mailparser": "^3.6.9",
"mysql2": "^3.9.7",
Expand Down
15 changes: 7 additions & 8 deletions apps/platform/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { authApi } from './routes/auth';
import { realtimeApi } from './routes/realtime';
import { trpcPlatformRouter } from './trpc';
import { db } from '@u22n/database';
import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
import { trpcServer } from '@hono/trpc-server';
import { authMiddleware } from './middlewares';
import { logger } from 'hono/logger';

Expand Down Expand Up @@ -38,18 +38,17 @@ app.route('/auth', authApi);
app.route('/realtime', realtimeApi);

// TRPC handler
app.use('/trpc/*', async (c) =>
fetchRequestHandler({
app.use(
'/trpc/*',
trpcServer({
router: trpcPlatformRouter,
createContext: () => ({
createContext: (_, c) => ({
db,
account: c.get('account'),
org: null,
event: c
}),
endpoint: '/trpc',
req: c.req.raw
}).then((res) => c.body(res.body, res))
})
})
);

// 404 handler
Expand Down
3 changes: 2 additions & 1 deletion apps/platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"dependencies": {
"@hono/node-server": "^1.11.1",
"@hono/trpc-server": "^0.3.1",
"@hono/zod-validator": "^0.2.1",
"@simplewebauthn/server": "^9.0.3",
"@t3-oss/env-core": "^0.10.1",
Expand All @@ -21,7 +22,7 @@
"@u22n/tsconfig": "^0.0.2",
"@u22n/utils": "workspace:^",
"@unkey/ratelimit": "^0.1.3",
"hono": "^4.3.6",
"hono": "^4.3.7",
"itty-time": "^1.0.6",
"lucia": "^3.1.1",
"oslo": "^1.1.3",
Expand Down
8 changes: 1 addition & 7 deletions apps/platform/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Hono } from 'hono';
import type { Ctx } from '../ctx';
import { lucia } from '../utils/auth';
import { setCookie } from 'hono/cookie';
import { convertLuciaAttributesToHono } from '../utils/misc';

export const authApi = new Hono<Ctx>();

Expand All @@ -22,11 +21,6 @@ authApi.post('/logout', async (c) => {
const sessionId = account.session.id;
await lucia.invalidateSession(sessionId);
const cookie = lucia.createBlankSessionCookie();
setCookie(
c,
cookie.name,
cookie.value,
convertLuciaAttributesToHono(cookie.attributes)
);
setCookie(c, cookie.name, cookie.value, cookie.attributes);
return c.json({ ok: true });
});
15 changes: 2 additions & 13 deletions apps/platform/trpc/routers/authRouter/passkeyRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { createLuciaSessionCookie } from '../../../utils/session';
import { env } from '../../../env';
import { ms } from 'itty-time';
import { getCookie, setCookie } from 'hono/cookie';
import { convertLuciaAttributesToHono } from '../../../utils/misc';

export const passkeyRouter = router({
signUpWithPasskeyStart: publicRateLimitedProcedure.signUpPasskeyStart
Expand Down Expand Up @@ -143,12 +142,7 @@ export const passkeyRouter = router({
username: input.username,
publicId: input.publicId
});
setCookie(
ctx.event,
cookie.name,
cookie.value,
convertLuciaAttributesToHono(cookie.attributes)
);
setCookie(ctx.event, cookie.name, cookie.value, cookie.attributes);
return { success: true };
}),

Expand Down Expand Up @@ -251,12 +245,7 @@ export const passkeyRouter = router({
os: os.name || 'Unknown'
});
const cookie = lucia.createSessionCookie(accountSession.id);
setCookie(
event,
cookie.name,
cookie.value,
convertLuciaAttributesToHono(cookie.attributes)
);
setCookie(event, cookie.name, cookie.value, cookie.attributes);

await db
.update(accounts)
Expand Down
29 changes: 4 additions & 25 deletions apps/platform/trpc/routers/authRouter/passwordRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { createLuciaSessionCookie } from '../../../utils/session';
import { decodeHex } from 'oslo/encoding';
import { TOTPController } from 'oslo/otp';
import { setCookie, getCookie, deleteCookie } from 'hono/cookie';
import { convertLuciaAttributesToHono } from '../../../utils/misc';
import { env } from '../../../env';
import { storage } from '../../../storage';

Expand Down Expand Up @@ -73,12 +72,7 @@ export const passwordRouter = router({
publicId
});

setCookie(
event,
cookie.name,
cookie.value,
convertLuciaAttributesToHono(cookie.attributes)
);
setCookie(event, cookie.name, cookie.value, cookie.attributes);
await db
.update(accounts)
.set({ lastLoginAt: new Date() })
Expand Down Expand Up @@ -176,12 +170,7 @@ export const passwordRouter = router({
publicId
});

setCookie(
event,
cookie.name,
cookie.value,
convertLuciaAttributesToHono(cookie.attributes)
);
setCookie(event, cookie.name, cookie.value, cookie.attributes);
deleteCookie(event, 'un-2fa-challenge');

await db
Expand Down Expand Up @@ -312,12 +301,7 @@ export const passwordRouter = router({
username,
publicId
});
setCookie(
event,
cookie.name,
cookie.value,
convertLuciaAttributesToHono(cookie.attributes)
);
setCookie(event, cookie.name, cookie.value, cookie.attributes);

await db
.update(accounts)
Expand Down Expand Up @@ -422,12 +406,7 @@ export const passwordRouter = router({
publicId: accountData.publicId
});

setCookie(
event,
cookie.name,
cookie.value,
convertLuciaAttributesToHono(cookie.attributes)
);
setCookie(event, cookie.name, cookie.value, cookie.attributes);
return { success: true };
})
});
8 changes: 1 addition & 7 deletions apps/platform/trpc/routers/authRouter/recoveryRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { createLuciaSessionCookie } from '../../../utils/session';
import { decodeHex } from 'oslo/encoding';
import { TOTPController } from 'oslo/otp';
import { setCookie } from 'hono/cookie';
import { convertLuciaAttributesToHono } from '../../../utils/misc';
import { env } from '../../../env';
import { storage } from '../../../storage';

Expand Down Expand Up @@ -136,12 +135,7 @@ export const recoveryRouter = router({
publicId
});

setCookie(
event,
cookie.name,
cookie.value,
convertLuciaAttributesToHono(cookie.attributes)
);
setCookie(event, cookie.name, cookie.value, cookie.attributes);

const authStorage = storage.auth;
const token = nanoIdToken();
Expand Down
11 changes: 0 additions & 11 deletions apps/platform/utils/misc.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@u22n/database": "workspace:*",
"@u22n/tsconfig": "^0.0.2",
"@u22n/utils": "workspace:*",
"hono": "^4.3.6",
"hono": "^4.3.7",
"sharp": "^0.33.2",
"unstorage": "^1.10.2",
"zod": "^3.23.8"
Expand Down
4 changes: 2 additions & 2 deletions ee/apps/billing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
},
"dependencies": {
"@hono/node-server": "^1.11.1",
"@hono/trpc-server": "^0.2.0",
"@hono/trpc-server": "^0.3.1",
"@hono/zod-validator": "^0.2.1",
"@t3-oss/env-core": "^0.10.1",
"@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2",
"@u22n/database": "workspace:*",
"@u22n/tsconfig": "^0.0.2",
"@u22n/utils": "workspace:*",
"hono": "^4.3.6",
"hono": "^4.3.7",
"nitropack": "^2.8.1",
"stripe": "^14.17.0",
"superjson": "^2.2.1",
Expand Down
Loading