mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Add stricter ESLint rules
This commit is contained in:
parent
887128356e
commit
e618996936
18 changed files with 102 additions and 63 deletions
|
|
@ -7,20 +7,20 @@ export interface ConfigType {
|
|||
username: string;
|
||||
password: string;
|
||||
database: string;
|
||||
}
|
||||
};
|
||||
http: {
|
||||
port: number;
|
||||
base_url: string;
|
||||
}
|
||||
[ key: string ]: unknown;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export const getConfig = () => {
|
||||
return data as ConfigType;
|
||||
}
|
||||
};
|
||||
|
||||
export const getHost = () => {
|
||||
const url = new URL(getConfig().http.base_url);
|
||||
|
||||
return url.host;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import { NodeObject } from "jsonld";
|
|||
export const jsonResponse = (data: object, status = 200) => {
|
||||
return new Response(JSON.stringify(data), {
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
status,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const jsonLdResponse = (data: NodeObject | APObject, status = 200) => {
|
||||
return new Response(JSON.stringify(data), {
|
||||
|
|
@ -20,7 +20,10 @@ export const jsonLdResponse = (data: NodeObject | APObject, status = 200) => {
|
|||
};
|
||||
|
||||
export const errorResponse = (error: string, status = 500) => {
|
||||
return jsonResponse({
|
||||
error: error
|
||||
}, status);
|
||||
}
|
||||
return jsonResponse(
|
||||
{
|
||||
error: error,
|
||||
},
|
||||
status
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue