Skip to content

Commit 7345989

Browse files
refactor(api): import add-donation schema (freeCodeCamp#55876)
1 parent e0bda03 commit 7345989

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

api/src/routes/donate.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
Type,
3-
type FastifyPluginCallbackTypebox
4-
} from '@fastify/type-provider-typebox';
1+
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox';
52
import Stripe from 'stripe';
63
import {
74
donationSubscriptionConfig,
@@ -62,22 +59,7 @@ export const donateRoutes: FastifyPluginCallbackTypebox = (
6259
fastify.post(
6360
'/donate/add-donation',
6461
{
65-
schema: {
66-
body: Type.Object({}),
67-
response: {
68-
200: Type.Object({
69-
isDonating: Type.Boolean()
70-
}),
71-
400: Type.Object({
72-
message: Type.Literal('User is already donating.'),
73-
type: Type.Literal('info')
74-
}),
75-
500: Type.Object({
76-
message: Type.Literal('Something went wrong.'),
77-
type: Type.Literal('danger')
78-
})
79-
}
80-
}
62+
schema: schemas.addDonation
8163
},
8264
async (req, reply) => {
8365
try {

api/src/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export { msTrophyChallengeCompleted } from './schemas/challenge/ms-trophy-challe
1111
export { projectCompleted } from './schemas/challenge/project-completed';
1212
export { saveChallenge } from './schemas/challenge/save-challenge';
1313
export { deprecatedEndpoints } from './schemas/deprecated';
14+
export { addDonation } from './schemas/donate/add-donation';
1415
export { chargeStripeCard } from './schemas/donate/charge-stripe-card';
1516
export { chargeStripe } from './schemas/donate/charge-stripe';
1617
export { createStripePaymentIntent } from './schemas/donate/create-stripe-payment-intent';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Type } from '@fastify/type-provider-typebox';
2+
3+
export const addDonation = {
4+
body: Type.Object({}),
5+
response: {
6+
200: Type.Object({
7+
isDonating: Type.Boolean()
8+
}),
9+
400: Type.Object({
10+
message: Type.Literal('User is already donating.'),
11+
type: Type.Literal('info')
12+
}),
13+
500: Type.Object({
14+
message: Type.Literal('Something went wrong.'),
15+
type: Type.Literal('danger')
16+
})
17+
}
18+
};

0 commit comments

Comments
 (0)