import express from 'express'; import { HybridTranslate } from './HybridTranslate'; export class TranslateServer { private queue: Array<any> = []; protected inprogress: boolean = false; protected app = express(); protected port = 3100; protected route = ""; protected hybridTranslator: HybridTranslate | undefined; async prepare(){ throw console.error("this is abstract"); } async listen() { //Import puppeteer function // await this.hybridTranslator.init(); await this.prepare(); this.app.get('/start', (request, response) => { response.status(200); response.json({ "status": "started" }); }); this.app.get('/stop', (request, response) => { // clearInterval(timerInterval); response.status(200); response.json({ "status": "stoped" }); }); this.app.use((req, res, next) => { if (this.inprogress) { this.queue.push({ req, res, next }); } else { next(); } }); this.app.use((req, res, next) => { if (this.queue.length > 0) { const queued = this.queue.shift(); queued.next(); } next(); }); this.app.get('/', (req, res) => res.send('Hi Hybrid')); //Initialises the express server on the port 30000 this.app.listen(this.port, "0.0.0.0", () => { console.log(`app listening to localhost:${this.port}!`); console.log("example http://localhost:3100/start"); console.log(`example http://localhost:${this.port+this.route}/`); }); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Browcore.ts | File | 6.46 KB | 0644 |
|
HybridTranslate.ts | File | 6.42 KB | 0644 |
|
HybridTranslateDeDe.ts | File | 2.33 KB | 0644 |
|
HybridTranslateDeFa.ts | File | 2.11 KB | 0644 |
|
HybridTranslateFaDe.ts | File | 3.08 KB | 0644 |
|
TranslateServer.ts | File | 1.71 KB | 0644 |
|
TranslateServerDeDe.ts | File | 979 B | 0644 |
|
TranslateServerDeFa.ts | File | 976 B | 0644 |
|
TranslateServerFaDe.ts | File | 971 B | 0644 |
|
generate-cookie.ts | File | 584 B | 0644 |
|
main.ts | File | 1.83 KB | 0644 |
|
server-de-fa.ts | File | 2.62 KB | 0644 |
|
server.ts | File | 611 B | 0644 |
|