Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import express from 'express'; import type { Express } from 'express'; import type { Server as ServerExpress } from 'http'; /** * Класс для открытия сервера для отрисовки и моделирования элементов */ class Server{ /** * Сервер на express */ app: Express; serv: ServerExpress; /** * Открывает сервер на заданном порту * @param port порт(по умолчанию 3000) * @returns Приложение */ constructor(port?:number){ this.app = express(); this.serv = this.app.listen(port?port:3000, () => { console.log(`Server is running at http://localhost:${port?port:3000}`); }); } /** * Функция путь, передает по определенному * пути html * `let serv = (new lle.Server()).way('', body.html);` * @param way путь по которому будет передан html * @param html сам html * @returns сервер */ way(way:string, html:string): Server{ this.app.get('/'+way, (req, res) => { res.send(html); }); return this; } /** * Закрываем сервер */ close():void{ this.serv.close(); } } export {Server}; |