Add several constants
This commit is contained in:
36
deno/content-types.ts
Normal file
36
deno/content-types.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { Extensible } from "./interfaces";
|
||||||
|
|
||||||
|
const contentTypes: Extensible = {
|
||||||
|
text: {
|
||||||
|
plain: "text/plain",
|
||||||
|
html: "text/html",
|
||||||
|
css: "text/css",
|
||||||
|
javascript: "text/javascript",
|
||||||
|
xml: "text/xml",
|
||||||
|
},
|
||||||
|
image: {
|
||||||
|
jpeg: "image/jpeg",
|
||||||
|
png: "image/png",
|
||||||
|
gif: "image/gif",
|
||||||
|
svgPlusXml: "image/svg+xml",
|
||||||
|
webp: "image/webp",
|
||||||
|
},
|
||||||
|
audio: {
|
||||||
|
"mpeg": "audio/mpeg",
|
||||||
|
"wav": "audio/wav",
|
||||||
|
},
|
||||||
|
video: {
|
||||||
|
mp4: "video/mp4",
|
||||||
|
webm: "video/webm",
|
||||||
|
xMsvideo: "video/x-msvideo",
|
||||||
|
},
|
||||||
|
application: {
|
||||||
|
json: "application/json",
|
||||||
|
pdf: "application/pdf",
|
||||||
|
zip: "application/zip",
|
||||||
|
xWwwFormUrlencoded: "x-www-form-urlencoded",
|
||||||
|
octetStream: "octet-stream",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export { contentTypes };
|
||||||
41
deno/http-codes.ts
Normal file
41
deno/http-codes.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Extensible } from "./interfaces";
|
||||||
|
|
||||||
|
type HttpCode = {
|
||||||
|
code: number;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
};
|
||||||
|
type Group = "success" | "redirection" | "clientErrors" | "serverErrors";
|
||||||
|
type CodeDefinitions = {
|
||||||
|
[K in Group]: {
|
||||||
|
[K: string]: HttpCode;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const httpCodes: CodeDefinitions & Extensible = {
|
||||||
|
success: {
|
||||||
|
OK: { code: 200, name: "OK", "description": "" },
|
||||||
|
Created: { code: 201, name: "Created" },
|
||||||
|
Accepted: { code: 202, name: "Accepted" },
|
||||||
|
NoContent: { code: 204, name: "No content" },
|
||||||
|
},
|
||||||
|
redirection: {
|
||||||
|
// later
|
||||||
|
},
|
||||||
|
clientErrors: {
|
||||||
|
BadRequest: { code: 400, name: "Bad Request" },
|
||||||
|
Unauthorized: { code: 401, name: "Unauthorized" },
|
||||||
|
Forbidden: { code: 403, name: "Forbidden" },
|
||||||
|
NotFound: { code: 404, name: "Not Found" },
|
||||||
|
MethodNotAllowed: { code: 405, name: "Method Not Allowed" },
|
||||||
|
NotAcceptable: { code: 406, name: "Not Acceptable" },
|
||||||
|
// More later
|
||||||
|
},
|
||||||
|
serverErrors: {
|
||||||
|
InternalServerError: { code: 500, name: "Internal Server Error" },
|
||||||
|
NotImplemented: { code: 500, name: "Not implemented" },
|
||||||
|
// more later
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export { httpCodes };
|
||||||
1
deno/interfaces.ts
Normal file
1
deno/interfaces.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export interface Extensible {}
|
||||||
Reference in New Issue
Block a user