refactor(api): import add-donation schema (#55876)

pull/55894/head
Oliver Eyton-Williams 2024-08-19 13:30:02 +02:00 committed by GitHub
parent e0bda03fbb
commit 7345989917
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 20 deletions

View File

@ -1,7 +1,4 @@
import { import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox';
Type,
type FastifyPluginCallbackTypebox
} from '@fastify/type-provider-typebox';
import Stripe from 'stripe'; import Stripe from 'stripe';
import { import {
donationSubscriptionConfig, donationSubscriptionConfig,
@ -62,22 +59,7 @@ export const donateRoutes: FastifyPluginCallbackTypebox = (
fastify.post( fastify.post(
'/donate/add-donation', '/donate/add-donation',
{ {
schema: { schema: schemas.addDonation
body: Type.Object({}),
response: {
200: Type.Object({
isDonating: Type.Boolean()
}),
400: Type.Object({
message: Type.Literal('User is already donating.'),
type: Type.Literal('info')
}),
500: Type.Object({
message: Type.Literal('Something went wrong.'),
type: Type.Literal('danger')
})
}
}
}, },
async (req, reply) => { async (req, reply) => {
try { try {

View File

@ -11,6 +11,7 @@ export { msTrophyChallengeCompleted } from './schemas/challenge/ms-trophy-challe
export { projectCompleted } from './schemas/challenge/project-completed'; export { projectCompleted } from './schemas/challenge/project-completed';
export { saveChallenge } from './schemas/challenge/save-challenge'; export { saveChallenge } from './schemas/challenge/save-challenge';
export { deprecatedEndpoints } from './schemas/deprecated'; export { deprecatedEndpoints } from './schemas/deprecated';
export { addDonation } from './schemas/donate/add-donation';
export { chargeStripeCard } from './schemas/donate/charge-stripe-card'; export { chargeStripeCard } from './schemas/donate/charge-stripe-card';
export { chargeStripe } from './schemas/donate/charge-stripe'; export { chargeStripe } from './schemas/donate/charge-stripe';
export { createStripePaymentIntent } from './schemas/donate/create-stripe-payment-intent'; export { createStripePaymentIntent } from './schemas/donate/create-stripe-payment-intent';

View File

@ -0,0 +1,18 @@
import { Type } from '@fastify/type-provider-typebox';
export const addDonation = {
body: Type.Object({}),
response: {
200: Type.Object({
isDonating: Type.Boolean()
}),
400: Type.Object({
message: Type.Literal('User is already donating.'),
type: Type.Literal('info')
}),
500: Type.Object({
message: Type.Literal('Something went wrong.'),
type: Type.Literal('danger')
})
}
};