@@ -8,28 +8,30 @@ import swagger from "@fastify/swagger"
88import swaggerUI from "@fastify/swagger-ui"
99import * as dotenv from "dotenv"
1010import fastify from "fastify"
11- import nodemailer , { type SentMessageInfo } from "nodemailer"
12- import type { DataSource } from "typeorm"
11+ import nodemailer , { SentMessageInfo } from "nodemailer"
1312import authRoutes from "./routes/v1/Auth/routes"
1413import { characterRoutes } from "./routes/v1/Characters/routes"
1514import profileRoutes from "./routes/v1/Profile/routes"
16- import verifyToken from "./utils/auth"
15+ import { authMiddleware , optionalAuthMiddleware } from "./utils/auth"
1716import connectDatabase from "./utils/database"
1817import { checkModAbovePermissions } from "./utils/permission"
1918import artRoutes from "./routes/v1/Art/routes"
2019import relationshipRoutes from "./routes/v1/Relationships/routes"
2120import StaffRoutes from "./routes/v1/Staff/routes"
2221import { oauthProviders } from "./config/oauth"
23- import fastifyOauth2 from "@fastify/oauth2"
22+ import fastifyOauth2 , { OAuth2Namespace } from "@fastify/oauth2"
2423import fastifySession from "@fastify/session"
2524import folderRoutes from "./routes/v1/Folder/routes"
2625import dashboardRoutes from "./routes/v1/Dashboard/routes"
26+ import { DataSource } from "typeorm"
27+ import { generalRoutes } from "./routes/v1/General/routes"
2728
2829declare module "fastify" {
2930 interface FastifyInstance {
3031 db : DataSource
3132 auth : any
3233 permissionAboveMod : any
34+ optionalAuth : any
3335 mailer : nodemailer . Transporter < SentMessageInfo >
3436 s3 : S3Client
3537 }
@@ -40,6 +42,11 @@ declare module "fastify" {
4042 profileId : string
4143 }
4244 }
45+
46+ interface FastifyInstance {
47+ facebookOAuth2 : OAuth2Namespace ;
48+ googleOAuth : OAuth2Namespace ;
49+ }
4350}
4451
4552const app = async ( ) => {
@@ -76,7 +83,8 @@ const app = async () => {
7683 // server.decorateRequest('db', connection);
7784
7885 // Auth Decorator
79- server . decorate ( "auth" , verifyToken )
86+ server . decorate ( "auth" , authMiddleware )
87+ server . decorate ( "optionalAuth" , optionalAuthMiddleware )
8088
8189 // Register all OAuth providers
8290 oauthProviders . forEach ( ( { name, config } ) => {
@@ -161,6 +169,7 @@ const app = async () => {
161169 server . register ( folderRoutes , { prefix : "/v1/folders" } )
162170 server . register ( dashboardRoutes , { prefix : "/v1/dashboard" } )
163171 server . register ( artRoutes , { prefix : "/v1/art" } )
172+ server . register ( generalRoutes , { prefix : "/v1" } )
164173 server . register ( StaffRoutes , { prefix : "/v1/staff" } )
165174
166175 // Starting server
0 commit comments