diff --git a/eslint.config.js b/eslint.config.js
index 68aade2..bdb6bfe 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -20,7 +20,7 @@ const pluginReact = eslintReact.configs.all.plugins
/** @type {import('eslint').Linter.Config[]} */
export default [
- { ignores: resolveIgnoresFromGitignore() },
+ { ignores: [...resolveIgnoresFromGitignore(), 'functions/lib/*'] },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
...neostandard({
diff --git a/functions/src/index.ts b/functions/src/index.ts
index 3cf5dc0..4aaf525 100644
--- a/functions/src/index.ts
+++ b/functions/src/index.ts
@@ -1,21 +1,34 @@
-/* eslint-disable @typescript-eslint/no-unused-vars */
+import { error as logger } from 'firebase-functions/logger'
+import { https } from 'firebase-functions/v2'
+import { defaultStyle, roundedStyle } from './primary'
-/**
- * Import function triggers from their respective submodules:
- *
- * import {onCall} from "firebase-functions/v2/https";
- * import {onDocumentWritten} from "firebase-functions/v2/firestore";
- *
- * See a full list of supported triggers at https://firebase.google.com/docs/functions
- */
+export const badge = https.onRequest(async (request, response) => {
+ const { query } = request
-import * as logger from 'firebase-functions/logger'
-import { onRequest } from 'firebase-functions/v2/https'
+ try {
+ let svgContent
-// Start writing functions
-// https://firebase.google.com/docs/functions/typescript
+ // Verificar que el método de la solicitud sea GET
+ if (request.method !== 'GET') {
+ response.status(405).send(`Método ${request.method} no permitido.`)
+ return
+ }
-// export const helloWorld = onRequest((request, response) => {
-// logger.info("Hello logs!", {structuredData: true});
-// response.send("Hello from Firebase!");
-// });
+ // Generar el contenido SVG
+ if (query.style === 'default') {
+ svgContent = defaultStyle(query)
+ }
+
+ if (query.style === 'rounded') {
+ svgContent = roundedStyle(query)
+ }
+
+ // Establecer el tipo de contenido como image/svg+xml
+ response.set('Content-Type', 'image/svg+xml')
+ response.status(200).send(svgContent)
+ } catch (error) {
+ // Registrar el error y devolver un mensaje genérico
+ logger('Error manejando la solicitud:', error)
+ response.status(500).send('Error de servidor.')
+ }
+})
diff --git a/functions/src/primary/default.ts b/functions/src/primary/default.ts
new file mode 100644
index 0000000..84ee9cf
--- /dev/null
+++ b/functions/src/primary/default.ts
@@ -0,0 +1,43 @@
+interface Query {
+ text: string
+}
+
+export function defaultStyle(query: Query): string {
+ const { text } = query
+
+ return `
+
+ `
+}
diff --git a/functions/src/primary/index.ts b/functions/src/primary/index.ts
new file mode 100644
index 0000000..32cfad8
--- /dev/null
+++ b/functions/src/primary/index.ts
@@ -0,0 +1,2 @@
+export * from './default'
+export * from './rounded'
diff --git a/functions/src/primary/rounded.ts b/functions/src/primary/rounded.ts
new file mode 100644
index 0000000..5d52942
--- /dev/null
+++ b/functions/src/primary/rounded.ts
@@ -0,0 +1,43 @@
+interface Query {
+ text: string
+}
+
+export function roundedStyle(query: Query): string {
+ const { text } = query
+
+ return `
+
+ `
+}