UNPKG

adfs_login_react_nds

Version:

This is a library that provides the necessary functions to install, configure, and connect a JavaScript application with Active Directory Federation Service. It allows for seamless integration with ADFS by providing the necessary parameters and dependenci

44 lines (35 loc) 1.26 kB
const fs = require("fs"); const path = require("path"); const serverFilePath = path.resolve(__dirname, "server.js"); const sslCertFilePath = path.resolve(__dirname, "certs", "localhost.cert"); const sslKeyFilePath = path.resolve(__dirname, "certs", "localhost.key"); // Verifica que los archivos de certificado y clave existan if (!fs.existsSync(sslKeyFilePath) || !fs.existsSync(sslCertFilePath)) { console.error("Certificados SSL no encontrados"); process.exit(1); } const serverCode = ` const express = require("express"); const https = require("https"); const fs = require("fs"); const next = require("next"); const dev = process.env.NODE_ENV !== "production"; const app = next({ dev }); const handle = app.getRequestHandler(); const httpsOptions = { cert: fs.readFileSync("${sslCertFilePath}") key: fs.readFileSync("${sslKeyFilePath}"), }; app.prepare().then(() => { const server = express(); server.get("*", (req, res) => { return handle(req, res); }); https.createServer(httpsOptions, server).listen(3000, err => { if (err) throw err; console.log("> Ready on https://localhost:3000"); }); }); `; fs.writeFileSync(serverFilePath, serverCode); console.log("Created server.js");