feat: refactor authentication and user management routes
- Removed the API proxy middleware and integrated RPC routes for user authentication. - Implemented JWT token generation and validation in the authentication middleware. - Enhanced user registration and login processes with password hashing and token management. - Added new routes for user password reset and Google OAuth login. - Introduced health check endpoints for service monitoring. - Updated gRPC client methods for user management, including password updates. - Refactored utility functions for token handling and Redis interactions. - Improved type definitions for better TypeScript support.
This commit is contained in:
@@ -4,6 +4,7 @@ import { contextStorage } from "hono/context-storage";
|
||||
import { cors } from "hono/cors";
|
||||
import { languageDetector } from "hono/language";
|
||||
import isMobile from "is-mobile";
|
||||
import { JwtProvider } from "../utils/token";
|
||||
type AppFetch = (
|
||||
input: string | Request | URL,
|
||||
requestInit?: RequestInit
|
||||
@@ -14,6 +15,9 @@ declare module "hono" {
|
||||
fetch: AppFetch;
|
||||
isMobile: boolean;
|
||||
redis: RedisClient;
|
||||
jwtProvider: JwtProvider;
|
||||
userId: string;
|
||||
role: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +33,11 @@ export function setupMiddlewares(app: Hono) {
|
||||
lookupFromHeaderKey: "accept-language",
|
||||
order: ["cookie", "header"],
|
||||
}),
|
||||
contextStorage()
|
||||
contextStorage(),
|
||||
async (c, next) => {
|
||||
c.set("jwtProvider", JwtProvider.newJWTProvider("your-secret-key"));
|
||||
await next();
|
||||
}
|
||||
);
|
||||
|
||||
app.use(cors(), async (c, next) => {
|
||||
@@ -44,7 +52,7 @@ export function setupMiddlewares(app: Hono) {
|
||||
await next();
|
||||
});
|
||||
app.use(async (c, next) => {
|
||||
client
|
||||
return await client
|
||||
.connect()
|
||||
.then(() => {
|
||||
c.set("redis", client);
|
||||
|
||||
Reference in New Issue
Block a user