Applying Prettier on pusher and back
This commit is contained in:
parent
06b7f5ba2f
commit
10c3d6dee2
71 changed files with 1848 additions and 1652 deletions
|
@ -1,11 +1,10 @@
|
|||
import {HttpResponse} from "uWebSockets.js";
|
||||
|
||||
import { HttpResponse } from "uWebSockets.js";
|
||||
|
||||
export class BaseController {
|
||||
protected addCorsHeaders(res: HttpResponse): void {
|
||||
res.writeHeader('access-control-allow-headers', 'Origin, X-Requested-With, Content-Type, Accept');
|
||||
res.writeHeader('access-control-allow-methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
|
||||
res.writeHeader('access-control-allow-origin', '*');
|
||||
res.writeHeader("access-control-allow-headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
res.writeHeader("access-control-allow-methods", "GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
res.writeHeader("access-control-allow-origin", "*");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,23 +15,23 @@ export class BaseController {
|
|||
if (e && e.message) {
|
||||
let url = e?.config?.url;
|
||||
if (url !== undefined) {
|
||||
url = ' for URL: '+url;
|
||||
url = " for URL: " + url;
|
||||
} else {
|
||||
url = '';
|
||||
url = "";
|
||||
}
|
||||
console.error('ERROR: '+e.message+url);
|
||||
} else if (typeof(e) === 'string') {
|
||||
console.error("ERROR: " + e.message + url);
|
||||
} else if (typeof e === "string") {
|
||||
console.error(e);
|
||||
}
|
||||
if (e.stack) {
|
||||
console.error(e.stack);
|
||||
}
|
||||
if (e.response) {
|
||||
res.writeStatus(e.response.status+" "+e.response.statusText);
|
||||
res.writeStatus(e.response.status + " " + e.response.statusText);
|
||||
this.addCorsHeaders(res);
|
||||
res.end("An error occurred: "+e.response.status+" "+e.response.statusText);
|
||||
res.end("An error occurred: " + e.response.status + " " + e.response.statusText);
|
||||
} else {
|
||||
res.writeStatus("500 Internal Server Error")
|
||||
res.writeStatus("500 Internal Server Error");
|
||||
this.addCorsHeaders(res);
|
||||
res.end("An error occurred");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue