@servant/servant
Version:
Servant builder for node modules.
3 lines (2 loc) • 4.98 kB
TypeScript
export declare const WebIndexTs = "\n/**\n * @summary Entry typescript file\n * @description\n * This is main file that is used as entry file into your package. Code in this project\n * is written in typescript language (@see https://www.typescriptlang.org/). There can\n * be exported functions, classes or types. This is content used for browsers mainly.\n * \n */\n\nexport function createScreen(parent: HTMLElement) {\n const screen = createDiv([\"container\"],\n [\n createDiv([\"content\"],\n [\n createDiv([\"logo\"], [createImage(\"logo.png\", \"Servant logo\")]),\n createDiv([\"title\"], [createText(\"Servant\")]),\n createDiv([\"description\"], [createText(\"Servant builder is simple build tool for developers, that wants to build and manage modularized large projects in monorepo or separated into more repositories.\")]),\n ])\n ]\n );\n parent.appendChild(screen);\n}\n\nfunction createText(text: string) {\n return document.createTextNode(text);\n}\n\nfunction createDiv(className: string[], children: Node[]) {\n const div = document.createElement('div');\n div.className = className.join(\" \");\n children.forEach((child) => {\n div.appendChild(child);\n });\n return div;\n}\n\nfunction createImage(url: string, alt: string) {\n const img = document.createElement('img');\n img.src = url;\n img.alt = alt;\n return img;\n}\n\n";
export declare const NodeIndexTs = "\n/**\n * @summary Entry typescript file\n * @description\n * This is main file that is used as entry file into your package. Code in this project\n * is written in typescript language (@see https://www.typescriptlang.org/). There can\n * be exported functions, classes or types. This is content used for node js or node cli\n * mainly.\n * \n */\n\nimport * as http from \"http\";\n\nconst hostname = '127.0.0.1';\nconst port = 3000;\n\n//language=html\nconst html = `\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>Servant nodejs project</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap\">\n <style>\n body {\n margin: 0;\n padding: 0;\n color: white;\n background: #282C34;\n font-family: \"Roboto\", sans-serif;\n }\n body .container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: row;\n align-content: center;\n justify-content: center;\n align-items: center;\n }\n body .container .content {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n body .container .content .logo {\n width: 30%;\n height: 30%;\n margin: auto;\n }\n body .container .content .logo img {\n width: 100%;\n height: 100%;\n }\n body .container .content .title {\n font-size: 40px;\n font-weight: bold;\n margin: 10px 0;\n }\n body .container .content .description {\n max-width: 400px;\n font-size: 16px;\n margin: 10px 0;\n color: #61DBFA;\n text-align: center;\n }\n </style>\n </head>\n <body>\n <div class=\"container\">\n <div class=\"content\">\n <div class=\"logo\"><img src=\"https://gitlab.com/stanislavhacker/servant/raw/master/assets/logo.png\" alt=\"Servant logo\"></div>\n <div class=\"title\">Servant</div>\n <div class=\"description\">Servant builder is simple build tool for developers, that wants to build and manage modularized large projects in monorepo or separated into more repositories.\n </div>\n </div>\n </div>\n </body>\n</html>\n`;\n\nexport function createServer(hostname: string, port: number, onDone: (hostname: string, port: number) => void): http.Server {\n const server = http.createServer((req, res) => {\n res.statusCode = 200;\n res.setHeader('Content-Type', 'text/html');\n res.end(html);\n });\n\n return server.listen(port, hostname, () => {\n onDone(hostname, port);\n });\n}\n\nif (require.main === module) {\n createServer(hostname, port, () => {\n console.log(\"This is a Servant generated nodejs project!\");\n console.log(`Server running at http://${hostname}:${port}`);\n });\n}\n\n";