Skip to content

Commit 7123c7b

Browse files
committed
add: comment for fastify plugin
1 parent 66c7eaf commit 7123c7b

File tree

8 files changed

+21
-1
lines changed

8 files changed

+21
-1
lines changed

apps/server/src/app.mts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import errorHandlerPlugin from '@plugins/global/errorHandlerPlugin.mjs'
1111
import ipaddrPlugin from '@plugins/global/ipaddrPlugin.mjs'
1212
import keepAlivePlugin from '@plugins/global/keepAlivePlugin.mjs'
1313
import mercuriusPlugin from '@plugins/global/mercuriusPlugin.mjs'
14+
import cors from '@fastify/cors'
1415

1516
const app = Fastify({
1617
logger: true,
@@ -20,7 +21,19 @@ const app = Fastify({
2021
app.register(cookie, { secret: ENV.cookieSecretKey })
2122
app.register(formbody)
2223

23-
app.register(corsPlugin)
24+
// await app.register(cors, {
25+
// credentials: true,
26+
// origin: (origin, callback) => {
27+
// callback(null, true)
28+
// // if (!origin || corsWhitelist.some((re) => re.test(origin))) {
29+
// // callback(null, true)
30+
// // } else {
31+
// // callback(new ForbiddenError('Not allow origin'), false)
32+
// // }
33+
// },
34+
// })
35+
36+
await app.register(corsPlugin)
2437
app.register(authPlugin)
2538
app.register(ipaddrPlugin)
2639
app.register(mercuriusPlugin)

apps/server/src/common/plugins/global/authPlugin.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { UserService } from '@services/UserService/index.js'
66
import { CookieService } from '@lib/cookie/CookieService.js'
77
import { Time } from '@constants/TimeConstants.js'
88

9+
// TODO: apply fastify-plugin
910
const authPlugin: FastifyPluginAsync = async (fastify) => {
1011
fastify.decorateRequest('user', null)
1112
fastify.addHook('preHandler', async (request, reply) => {

apps/server/src/common/plugins/global/corsPlugin.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import cors from '@fastify/cors'
33
import { ForbiddenError } from '@errors/ForbiddenError.js'
44
import { ENV } from 'src/env.mjs'
55

6+
// TODO: apply fastify-plugin
67
const corsPlugin: FastifyPluginAsync = async (fastify) => {
78
const corsWhitelist: RegExp[] = [
89
/^https:\/\/velog.io$/,

apps/server/src/common/plugins/global/errorHandlerPlugin.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DiscordService } from '@lib/discord/DiscordService.js'
44
import { FastifyPluginCallback } from 'fastify'
55
import { container } from 'tsyringe'
66

7+
// TODO: apply fastify-plugin
78
const errorHandlerPlugin: FastifyPluginCallback = (fastify, _, done) => {
89
fastify.addHook('preHandler', function (request, reply, done) {
910
if (request.body) {

apps/server/src/common/plugins/global/ipaddrPlugin.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { FastifyPluginAsync } from 'fastify'
22

3+
// TODO: apply fastify-plugin
34
const ipaddrPlugin: FastifyPluginAsync = async (fastify) => {
45
fastify.decorateRequest('ipaddr', null)
56
fastify.addHook('preHandler', (request, reply, done) => {

apps/server/src/common/plugins/global/keepAlivePlugin.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const startClosing = () => {
55
isClosing = true
66
}
77

8+
// TODO: apply fastify-plugin
89
const keepAlivePlugin: FastifyPluginAsync = async (fastify) => {
910
fastify.addHook('onRequest', (_, reply, done) => {
1011
if (isClosing) {

apps/server/src/common/plugins/global/mercuriusPlugin.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { isHttpError } from '@errors/HttpError.js'
77
import { container } from 'tsyringe'
88
import { DiscordService } from '@lib/discord/DiscordService.js'
99

10+
// TODO: apply fastify-plugin'
1011
const mercuriusPlugin: FastifyPluginAsync = async (fastify) => {
1112
fastify.register(mercurius, {
1213
logLevel: 'error',

apps/server/src/common/plugins/global/validatorCompilerPlugin.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const schemaCompilers = {
2525
}),
2626
}
2727

28+
// TODO: apply fastify-plugin
2829
const validatorCompiler: FastifyPluginAsync = async (fastify) => {
2930
fastify.setValidatorCompiler((request) => {
3031
if (!request.httpPart) {

0 commit comments

Comments
 (0)