diff --git a/esbuild-prod.js b/esbuild-prod.js index 78934f6..c0575ab 100644 --- a/esbuild-prod.js +++ b/esbuild-prod.js @@ -4,6 +4,29 @@ const path = require("path"); const fs = require("fs"); const { glob } = require("glob"); +const buildHydration = (path) => { + build({ + platform: "browser", + entryPoints: [ + path, + ], + bundle: true, + minify: true, + sourcemap: false, + logLevel: "info", + plugins: [ + solidPlugin({ + solid: { + generate: "dom", + hydratable: true, + }, + }) + ], + outdir: "static", + format: "cjs", + }); +} + (async() => { const files = await glob("dist/**/*.jsx"); @@ -26,44 +49,6 @@ const { glob } = require("glob"); }); })(); -build({ - platform: "browser", - entryPoints: [ - "src/views/hydration.ts", - ], - bundle: true, - minify: true, - sourcemap: false, - logLevel: "info", - plugins: [ - solidPlugin({ - solid: { - generate: "dom", - hydratable: true, - }, - }) - ], - outdir: "static", - format: "cjs", -}); - -build({ - platform: "browser", - entryPoints: [ - "src/views/hydration/hydration_aulavirtual.ts", - ], - bundle: true, - minify: true, - sourcemap: false, - logLevel: "info", - plugins: [ - solidPlugin({ - solid: { - generate: "dom", - hydratable: true, - }, - }) - ], - outdir: "static", - format: "cjs", -}); +buildHydration("src/views/hydration.ts"); +buildHydration("src/views/hydration/hydration_aulavirtual.ts"); +buildHydration("src/views/hydration/hydration_batch_mode.ts"); diff --git a/esbuild.js b/esbuild.js index 0b644c6..2230adc 100644 --- a/esbuild.js +++ b/esbuild.js @@ -1,9 +1,32 @@ -const { build, context } = require("esbuild"); +const { context } = require("esbuild"); const { solidPlugin } = require("esbuild-plugin-solid"); -const path = require("path"); -const fs = require("fs"); const { glob } = require("glob"); +const genHydration = (path) => async () => { + const ctx = await context({ + platform: "browser", + entryPoints: [ + path, + ], + bundle: true, + minify: false, + logLevel: "info", + plugins: [ + solidPlugin({ + solid: { + generate: "dom", + hydratable: true, + }, + }) + ], + outdir: "static", + format: "cjs", + }); + + await ctx.watch(); + console.log("Watching hydration script..."); +}; + /** * Compile JSX files */ @@ -34,52 +57,6 @@ const { glob } = require("glob"); /** * Generate hydration script */ -(async () => { - const ctx = await context({ - platform: "browser", - entryPoints: [ - "src/views/hydration.ts", - ], - bundle: true, - minify: false, - logLevel: "info", - plugins: [ - solidPlugin({ - solid: { - generate: "dom", - hydratable: true, - }, - }) - ], - outdir: "static", - format: "cjs", - }); - - await ctx.watch(); - console.log("Watching hydration script..."); -})(); - -(async () => { - const ctx = await context({ - platform: "browser", - entryPoints: [ - "src/views/hydration/hydration_aulavirtual.ts", - ], - bundle: true, - minify: false, - logLevel: "info", - plugins: [ - solidPlugin({ - solid: { - generate: "dom", - hydratable: true, - }, - }) - ], - outdir: "static", - format: "cjs", - }); - - await ctx.watch(); - console.log("Watching hydration script..."); -})(); +(genHydration("src/views/hydration.ts"))(); +(genHydration("src/views/hydration/hydration_aulavirtual.ts"))(); +(genHydration("src/views/hydration/hydration_batch_mode.ts"))(); diff --git a/src/app.module.ts b/src/app.module.ts index 0f0b46a..9621f59 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -11,6 +11,7 @@ import { SubjectController } from "./controller/subject/subject.controller"; import { SubjectService } from "./controller/subject/subject.service"; import * as dotenv from "dotenv"; import { AulaVirtualController } from "./controller/aulavirtual/aulavirtual.controller"; +import { BatchCertController } from "./controller/batch_certs/BatchCerts.controller"; // Must be done before initializing DB. console.log(dotenv.config()); @@ -45,7 +46,13 @@ const db = process.env.MY_SQL_DB; synchronize: false, }), ], - controllers: [CertificateController, PersonController, SubjectController, AulaVirtualController], + controllers: [ + CertificateController, + PersonController, + SubjectController, + AulaVirtualController, + BatchCertController, + ], providers: [CertificateService, PersonService, SubjectService], }) export class AppModule {} diff --git a/src/controller/batch_certs/BatchCerts.controller.ts b/src/controller/batch_certs/BatchCerts.controller.ts new file mode 100644 index 0000000..b0298a0 --- /dev/null +++ b/src/controller/batch_certs/BatchCerts.controller.ts @@ -0,0 +1,13 @@ +import { Controller, Get } from "@nestjs/common"; +import { renderToString } from "solid-js/web"; +import { CertsBatch } from "src/views/BatchCerts"; +import { template } from "./BatchCerts.template"; + +@Controller("batch-certs") +export class BatchCertController { + @Get() + entry(): string { + const html = renderToString(CertsBatch); + return template(html); + } +} diff --git a/src/controller/batch_certs/BatchCerts.template.ts b/src/controller/batch_certs/BatchCerts.template.ts new file mode 100644 index 0000000..8b23cdf --- /dev/null +++ b/src/controller/batch_certs/BatchCerts.template.ts @@ -0,0 +1,28 @@ +import { generateHydrationScript } from "solid-js/web"; + +export function template(ssr: string): string { + return ` + + +
+
+ Inserta dnis separados por comas, espacios, etc. Los DNIs se separan con
+ la expresión /\d+/g
.
+