new(core.gbapp): New API endpoint.
This commit is contained in:
parent
0537e6f173
commit
7c208954f3
1 changed files with 60 additions and 43 deletions
45
src/app.ts
45
src/app.ts
|
@ -251,6 +251,22 @@ export class GBServer {
|
|||
winston.default(server, loggers[1]);
|
||||
}
|
||||
|
||||
|
||||
server.post('*', async (req, res, next) => {
|
||||
|
||||
const host = req.headers.host;
|
||||
|
||||
// Roteamento com base no domínio.
|
||||
|
||||
if (host === process.env.API_HOST) {
|
||||
GBLog.info(`Redirecting to API...`);
|
||||
return httpProxy.web(req, res, { target: 'http://localhost:1111' }); // Express server
|
||||
}
|
||||
|
||||
await GBSSR.ssrFilter(req, res, next);
|
||||
|
||||
});
|
||||
|
||||
server.get('*', async (req, res, next) => {
|
||||
|
||||
const host = req.headers.host;
|
||||
|
@ -282,20 +298,6 @@ export class GBServer {
|
|||
}
|
||||
});
|
||||
|
||||
GBLog.info(`The Bot Server is in RUNNING mode...`);
|
||||
|
||||
// Opens Navigator.
|
||||
|
||||
if (process.env.DEV_OPEN_BROWSER) {
|
||||
core.openBrowserInDevelopment();
|
||||
}
|
||||
} catch (err) {
|
||||
GBLog.error(`STOP: ${err.message ? err.message : err} ${err.stack ? err.stack : ''}`);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
// Setups unsecure http redirect.
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
|
@ -338,6 +340,21 @@ export class GBServer {
|
|||
else {
|
||||
server.listen(port, mainCallback);
|
||||
}
|
||||
|
||||
GBLog.info(`The Bot Server is in RUNNING mode...`);
|
||||
|
||||
// Opens Navigator.
|
||||
|
||||
if (process.env.DEV_OPEN_BROWSER) {
|
||||
core.openBrowserInDevelopment();
|
||||
}
|
||||
} catch (err) {
|
||||
GBLog.error(`STOP: ${err.message ? err.message : err} ${err.stack ? err.stack : ''}`);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static initEndpointsDocs(app: express.Application) {
|
||||
|
|
Loading…
Add table
Reference in a new issue