@torpor/build 0.1.34 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/dist/RouteType-g8Ce5gOd.js +107 -0
- package/dist/RouteType-g8Ce5gOd.js.map +1 -0
- package/dist/Server-CSpY_-Ba.d.ts +78 -0
- package/dist/Server-CSpY_-Ba.d.ts.map +1 -0
- package/dist/ServerEvent-2-CnAy1W.js +74 -0
- package/dist/ServerEvent-2-CnAy1W.js.map +1 -0
- package/dist/Site-D4x1l0p5.d.ts +67 -0
- package/dist/Site-D4x1l0p5.d.ts.map +1 -0
- package/dist/_page-CsdPubw4.js +33 -0
- package/dist/_page-CsdPubw4.js.map +1 -0
- package/dist/bin/index.d.ts +1 -1
- package/dist/bin/index.js +14 -19
- package/dist/bin/index.js.map +1 -1
- package/dist/connectMiddleware-DbLj0St1.js +252 -0
- package/dist/connectMiddleware-DbLj0St1.js.map +1 -0
- package/dist/index.d.ts +191 -182
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -145
- package/dist/index.js.map +1 -1
- package/dist/nav.d.ts +14 -0
- package/dist/nav.d.ts.map +1 -0
- package/dist/nav.js +184 -0
- package/dist/nav.js.map +1 -0
- package/dist/pathToRegex-CTgx7hQP.js +11 -0
- package/dist/pathToRegex-CTgx7hQP.js.map +1 -0
- package/dist/response-D-XpIuMH.js +307 -0
- package/dist/response-D-XpIuMH.js.map +1 -0
- package/dist/response.d.ts +336 -151
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +4 -37
- package/dist/run-CNdaKSPR.js +331 -0
- package/dist/run-CNdaKSPR.js.map +1 -0
- package/dist/run.d.ts +11 -8
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +8 -18
- package/dist/seeOther-BmehiI4C.js +110 -0
- package/dist/seeOther-BmehiI4C.js.map +1 -0
- package/dist/server.d.ts +12 -11
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +5 -18
- package/dist/state.d.ts +14 -10
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +3 -7
- package/dist/test.d.ts +12 -11
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +152 -225
- package/dist/test.js.map +1 -1
- package/package.json +25 -29
- package/src/bin/index.ts +9 -11
- package/src/index.ts +3 -0
- package/src/nav/load.ts +9 -0
- package/src/nav/loadData.ts +121 -0
- package/src/nav/navigate.ts +154 -0
- package/src/nav/reload.ts +9 -0
- package/src/nav.ts +4 -0
- package/src/response/badRequest.ts +9 -4
- package/src/response/created.ts +10 -3
- package/src/response/forbidden.ts +11 -4
- package/src/response/found.ts +30 -0
- package/src/response/methodNotAllowed.ts +8 -4
- package/src/response/movedPermanently.ts +25 -0
- package/src/response/notFound.ts +14 -7
- package/src/response/notModified.ts +24 -4
- package/src/response/ok.ts +19 -10
- package/src/response/permanentRedirect.ts +30 -0
- package/src/response/seeOther.ts +9 -3
- package/src/response/serverError.ts +14 -2
- package/src/response/temporaryRedirect.ts +31 -0
- package/src/response/unauthorized.ts +11 -4
- package/src/response/unprocessable.ts +8 -2
- package/src/response.ts +8 -4
- package/src/run/prepareTemplate.ts +32 -0
- package/src/{site → run}/run.ts +1 -1
- package/src/{site → run}/runBuild.ts +2 -2
- package/src/{site → run}/runDev.ts +2 -2
- package/src/{site → run}/runPreview.ts +12 -2
- package/src/run.ts +4 -4
- package/src/server/Routerx.ts +3 -3
- package/src/server/Server.ts +3 -3
- package/src/server/ServerEvent.ts +1 -1
- package/src/server/connect/bufferToArrayBuffer.ts +8 -0
- package/src/server/connect/connectMiddleware.ts +4 -2
- package/src/server/connect/nodeMessageToNodeResponse.ts +2 -2
- package/src/server/types/ServerFunction.ts +3 -1
- package/src/site/Router.ts +3 -3
- package/src/site/clientEntry.ts +40 -273
- package/src/site/defaultAdapter.ts +1 -1
- package/src/site/serverEntry.ts +86 -50
- package/src/state/$page.ts +3 -12
- package/src/state/client.ts +6 -0
- package/src/state/internal.ts +45 -0
- package/src/test/runTest.ts +4 -4
- package/src/types/Adapter.ts +2 -4
- package/src/types/ClientState.ts +8 -0
- package/src/types/InternalState.ts +7 -0
- package/src/types/LayoutHandler.ts +2 -4
- package/src/types/LayoutPath.ts +10 -0
- package/src/types/ManifestRoute.ts +2 -4
- package/src/types/PageEndPoint.ts +5 -5
- package/src/types/PageLoadEvent.ts +2 -4
- package/src/types/PageServerAction.ts +1 -1
- package/src/types/PageServerEndPoint.ts +2 -4
- package/src/types/PageServerLoad.ts +1 -1
- package/src/types/PageState.ts +8 -0
- package/src/types/RouteHandler.ts +2 -4
- package/src/types/RouteLayoutHandler.ts +2 -4
- package/src/types/RouteMatchResult.ts +2 -4
- package/src/types/ServerHook.ts +3 -7
- package/src/types/ServerLoadEvent.ts +2 -4
- package/src/types/ServerRequest.ts +1 -1
- package/src/{site → utils}/pathToRegex.ts +1 -1
- package/{tsup.config.ts → tsdown.config.ts} +3 -4
- package/dist/Server-BC_dixZQ.d.cts +0 -71
- package/dist/Server-BC_dixZQ.d.ts +0 -71
- package/dist/Site-4tGiw2-I.d.ts +0 -63
- package/dist/Site-BXX-S541.d.cts +0 -63
- package/dist/bin/index.cjs +0 -755
- package/dist/bin/index.cjs.map +0 -1
- package/dist/bin/index.d.cts +0 -1
- package/dist/chunk-565UOT3F.js +0 -18
- package/dist/chunk-565UOT3F.js.map +0 -1
- package/dist/chunk-B2UNTYN5.js +0 -68
- package/dist/chunk-B2UNTYN5.js.map +0 -1
- package/dist/chunk-KKFND4HK.js +0 -85
- package/dist/chunk-KKFND4HK.js.map +0 -1
- package/dist/chunk-LO7P2LJE.js +0 -278
- package/dist/chunk-LO7P2LJE.js.map +0 -1
- package/dist/chunk-PTVHEJZ5.js +0 -152
- package/dist/chunk-PTVHEJZ5.js.map +0 -1
- package/dist/chunk-RHDSM5GS.js +0 -357
- package/dist/chunk-RHDSM5GS.js.map +0 -1
- package/dist/chunk-SJVHHGVW.js +0 -13
- package/dist/chunk-SJVHHGVW.js.map +0 -1
- package/dist/chunk-WVXAN4IV.js +0 -50
- package/dist/chunk-WVXAN4IV.js.map +0 -1
- package/dist/index.cjs +0 -322
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -199
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
- package/dist/response.cjs +0 -150
- package/dist/response.cjs.map +0 -1
- package/dist/response.d.cts +0 -166
- package/dist/response.js.map +0 -1
- package/dist/run.cjs +0 -764
- package/dist/run.cjs.map +0 -1
- package/dist/run.d.cts +0 -14
- package/dist/run.js.map +0 -1
- package/dist/server.cjs +0 -390
- package/dist/server.cjs.map +0 -1
- package/dist/server.d.cts +0 -17
- package/dist/server.js.map +0 -1
- package/dist/state.cjs +0 -44
- package/dist/state.cjs.map +0 -1
- package/dist/state.d.cts +0 -11
- package/dist/state.js.map +0 -1
- package/dist/test.cjs +0 -538
- package/dist/test.cjs.map +0 -1
- package/dist/test.d.cts +0 -15
- package/src/response/moved.ts +0 -16
- package/src/response/redirect.ts +0 -17
- package/src/site/prepareTemplate.ts +0 -20
- package/src/state/Page.ts +0 -8
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { response, transfer } from "./seeOther-BmehiI4C.js";
|
|
2
|
+
|
|
3
|
+
//#region src/response/badRequest.ts
|
|
4
|
+
/**
|
|
5
|
+
* 400 Bad Request
|
|
6
|
+
*
|
|
7
|
+
* The HTTP 400 Bad Request client error response status code indicates that the
|
|
8
|
+
* server would not process the request due to something the server considered
|
|
9
|
+
* to be a client error. The reason for a 400 response is typically due to
|
|
10
|
+
* malformed request syntax, invalid request message framing, or deceptive
|
|
11
|
+
* request routing.
|
|
12
|
+
*
|
|
13
|
+
* Clients that receive a 400 response should expect that repeating the request
|
|
14
|
+
* without modification will fail with the same error.
|
|
15
|
+
*
|
|
16
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/400
|
|
17
|
+
*/
|
|
18
|
+
function badRequest(body) {
|
|
19
|
+
return response(400, body ?? "Bad request");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/response/created.ts
|
|
24
|
+
/**
|
|
25
|
+
* 201 Created
|
|
26
|
+
*
|
|
27
|
+
* The HTTP 201 Created successful response status code indicates that the HTTP
|
|
28
|
+
* request has led to the creation of a resource. This status code is commonly
|
|
29
|
+
* sent as the result of a POST request.
|
|
30
|
+
*
|
|
31
|
+
* The new resource, or a description and link to the new resource, is created
|
|
32
|
+
* before the response is returned. The newly-created items can be returned in
|
|
33
|
+
* the body of the response message, but must be locatable by the URL of the
|
|
34
|
+
* initiating request or by the URL in the value of the Location header provided
|
|
35
|
+
* with the response.
|
|
36
|
+
*
|
|
37
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/201
|
|
38
|
+
*/
|
|
39
|
+
function created(body) {
|
|
40
|
+
return response(201, body);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/response/forbidden.ts
|
|
45
|
+
/**
|
|
46
|
+
* 403 Forbidden
|
|
47
|
+
*
|
|
48
|
+
* The HTTP 403 Forbidden client error response status code indicates that the
|
|
49
|
+
* server understood the request but refused to process it. This status is
|
|
50
|
+
* similar to 401, except that for 403 Forbidden responses, authenticating or
|
|
51
|
+
* re-authenticating makes no difference. The request failure is tied to
|
|
52
|
+
* application logic, such as insufficient permissions to a resource or action.
|
|
53
|
+
*
|
|
54
|
+
* Clients that receive a 403 response should expect that repeating the request
|
|
55
|
+
* without modification will fail with the same error. Server owners may decide
|
|
56
|
+
* to send a 404 response instead of a 403 if acknowledging the existence of a
|
|
57
|
+
* resource to clients with insufficient privileges is not desired.
|
|
58
|
+
*
|
|
59
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
|
|
60
|
+
*/
|
|
61
|
+
function forbidden(body) {
|
|
62
|
+
return response(403, body ?? "Forbidden");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/response/found.ts
|
|
67
|
+
/**
|
|
68
|
+
* 302 Found
|
|
69
|
+
*
|
|
70
|
+
* The HTTP 302 Found redirection response status code indicates that the
|
|
71
|
+
* requested resource has been temporarily moved to the URL in the Location
|
|
72
|
+
* header.
|
|
73
|
+
*
|
|
74
|
+
* A browser receiving this status will automatically request the resource at
|
|
75
|
+
* the URL in the Location header, redirecting the user to the new page. Search
|
|
76
|
+
* engines receiving this response will not attribute links to the original URL
|
|
77
|
+
* to the new resource, meaning no SEO value is transferred to the new URL.
|
|
78
|
+
*
|
|
79
|
+
* > Note: In the Fetch Standard, when a user agent receives a 302 in response
|
|
80
|
+
* > to a POST request, it uses the GET method in the subsequent redirection
|
|
81
|
+
* > request, as permitted by the HTTP specification. To avoid user agents
|
|
82
|
+
* > modifying the request, use 307 Temporary Redirect instead, as altering the
|
|
83
|
+
* > method after a 307 response is prohibited.
|
|
84
|
+
*
|
|
85
|
+
* > In cases where you want any request method to be changed to GET, use 303
|
|
86
|
+
* > See Other. This is useful when you want to give a response to a PUT method
|
|
87
|
+
* > that is not the uploaded resource but a confirmation message such as: "you
|
|
88
|
+
* > successfully uploaded XYZ".
|
|
89
|
+
*
|
|
90
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302
|
|
91
|
+
*/
|
|
92
|
+
function permRedirect(location) {
|
|
93
|
+
return transfer(308, location);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/response/methodNotAllowed.ts
|
|
98
|
+
/**
|
|
99
|
+
* 405 Method Not Allowed
|
|
100
|
+
*
|
|
101
|
+
* The HTTP 405 Method Not Allowed client error response status code indicates
|
|
102
|
+
* that the server knows the request method, but the target resource doesn't
|
|
103
|
+
* support this method. The server must generate an Allow header in a 405
|
|
104
|
+
* response with a list of methods that the target resource currently supports.
|
|
105
|
+
*
|
|
106
|
+
* Improper server-side permissions set on files or directories may cause a 405
|
|
107
|
+
* response when the request would otherwise be expected to succeed.
|
|
108
|
+
*
|
|
109
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/405
|
|
110
|
+
*/
|
|
111
|
+
function methodNotAllowed(body) {
|
|
112
|
+
return response(405, body ?? "Method not allowed");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/response/movedPermanently.ts
|
|
117
|
+
/**
|
|
118
|
+
* 301 Moved Permanently
|
|
119
|
+
*
|
|
120
|
+
* The HTTP 301 Moved Permanently redirection response status code indicates
|
|
121
|
+
* that the requested resource has been permanently moved to the URL in the
|
|
122
|
+
* Location header.
|
|
123
|
+
*
|
|
124
|
+
* A browser receiving this status will automatically request the resource at
|
|
125
|
+
* the URL in the Location header, redirecting the user to the new page. Search
|
|
126
|
+
* engines receiving this response will attribute links to the original URL to
|
|
127
|
+
* the redirected resource, passing the SEO ranking to the new URL.
|
|
128
|
+
*
|
|
129
|
+
* > Note: In the Fetch Standard, when a user agent receives a 301 in response
|
|
130
|
+
* > to a POST request, it uses the GET method in the subsequent redirection
|
|
131
|
+
* > request, as permitted by the HTTP specification. To avoid user agents
|
|
132
|
+
* > modifying the request, use 308 Permanent Redirect instead, as altering the
|
|
133
|
+
* > method after a 308 response is prohibited.
|
|
134
|
+
*
|
|
135
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301
|
|
136
|
+
*/
|
|
137
|
+
function permRedirect$1(location) {
|
|
138
|
+
return transfer(308, location);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/response/notModified.ts
|
|
143
|
+
/**
|
|
144
|
+
* 304 Not Modified
|
|
145
|
+
*
|
|
146
|
+
* The HTTP 304 Not Modified redirection response status code indicates that
|
|
147
|
+
* there is no need to retransmit the requested resources.
|
|
148
|
+
*
|
|
149
|
+
* This response code is sent when the request is a conditional GET or HEAD
|
|
150
|
+
* request with an If-None-Match or an If-Modified-Since header and the
|
|
151
|
+
* condition evaluates to 'false'. It confirms that the resource cached by the
|
|
152
|
+
* client is still valid and that the server would have sent a 200 OK response
|
|
153
|
+
* with the resource if the condition evaluated to 'true'. See HTTP caching for
|
|
154
|
+
* more information.
|
|
155
|
+
*
|
|
156
|
+
* The response must not contain a body and must include the headers that would
|
|
157
|
+
* have been sent in an equivalent 200 response, such as:
|
|
158
|
+
*
|
|
159
|
+
* - Cache-Control
|
|
160
|
+
* - Content-Location
|
|
161
|
+
* - Date
|
|
162
|
+
* - ETag
|
|
163
|
+
* - Expires
|
|
164
|
+
* - Vary
|
|
165
|
+
*
|
|
166
|
+
* > Note: Many developer tools' network panels of browsers create extraneous
|
|
167
|
+
* > requests leading to 304 responses, so that access to the local cache is
|
|
168
|
+
* > visible to developers.
|
|
169
|
+
*
|
|
170
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/304
|
|
171
|
+
*/
|
|
172
|
+
function notModified(location) {
|
|
173
|
+
return transfer(304, location);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/response/permanentRedirect.ts
|
|
178
|
+
/**
|
|
179
|
+
* 308 Permanent Redirect
|
|
180
|
+
*
|
|
181
|
+
* The HTTP 308 Permanent Redirect redirection response status code indicates
|
|
182
|
+
* that the requested resource has been permanently moved to the URL given by
|
|
183
|
+
* the Location header.
|
|
184
|
+
*
|
|
185
|
+
* A browser receiving this status will automatically request the resource at
|
|
186
|
+
* the URL in the Location header, redirecting the user to the new page. Search
|
|
187
|
+
* engines receiving this response will attribute links to the original URL to
|
|
188
|
+
* the redirected resource, passing the SEO ranking to the new URL.
|
|
189
|
+
*
|
|
190
|
+
* The request method and the body will not be modified by the client in the
|
|
191
|
+
* redirected request. A 301 Moved Permanently requires the request method and
|
|
192
|
+
* the body to remain unchanged when redirection is performed, but this is
|
|
193
|
+
* incorrectly handled by older clients to use the GET method instead.
|
|
194
|
+
*
|
|
195
|
+
* > Note: Some Web applications may use the 308 Permanent Redirect in a
|
|
196
|
+
* > non-standard way and for different purposes. For example, Google Drive uses
|
|
197
|
+
* > a 308 Resume Incomplete response to indicate to the client when an
|
|
198
|
+
* > unfinished upload has stalled. See Perform a resumable download on the
|
|
199
|
+
* > Google Drive documentation for more information.
|
|
200
|
+
*
|
|
201
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308
|
|
202
|
+
*/
|
|
203
|
+
function permanentRedirect(location) {
|
|
204
|
+
return transfer(308, location);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/response/serverError.ts
|
|
209
|
+
/**
|
|
210
|
+
* 500 Server Error
|
|
211
|
+
*
|
|
212
|
+
* The HTTP 500 Internal Server Error server error response status code
|
|
213
|
+
* indicates that the server encountered an unexpected condition that prevented
|
|
214
|
+
* it from fulfilling the request. This error is a generic "catch-all" response
|
|
215
|
+
* to server issues, indicating that the server cannot find a more appropriate
|
|
216
|
+
* 5XX error to respond with.
|
|
217
|
+
*
|
|
218
|
+
* If you're a visitor seeing 500 errors on a web page, these issues require
|
|
219
|
+
* investigation by server owners or administrators. There are many possible
|
|
220
|
+
* causes of 500 errors, including: improper server configuration, out-of-memory
|
|
221
|
+
* (OOM) issues, unhandled exceptions, improper file permissions, or other
|
|
222
|
+
* complex factors. Server administrators may proactively log occurrences of
|
|
223
|
+
* server error responses, like the 500 status code, with details about the
|
|
224
|
+
* initiating requests to improve the stability of a service in the future.
|
|
225
|
+
*
|
|
226
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500
|
|
227
|
+
*/
|
|
228
|
+
function serverError(body) {
|
|
229
|
+
return response(500, body ?? "Server error");
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/response/temporaryRedirect.ts
|
|
234
|
+
/**
|
|
235
|
+
* 307 Temporary Redirect
|
|
236
|
+
*
|
|
237
|
+
* The HTTP 307 Temporary Redirect redirection response status code indicates
|
|
238
|
+
* that the resource requested has been temporarily moved to the URL in the
|
|
239
|
+
* Location header.
|
|
240
|
+
*
|
|
241
|
+
* A browser receiving this status will automatically request the resource at
|
|
242
|
+
* the URL in the Location header, redirecting the user to the new page. Search
|
|
243
|
+
* engines receiving this response will not attribute links to the original URL
|
|
244
|
+
* to the new resource, meaning no SEO value is transferred to the new URL.
|
|
245
|
+
*
|
|
246
|
+
* The method and the body of the original request are reused to perform the
|
|
247
|
+
* redirected request. In the cases where you want the request method to be
|
|
248
|
+
* changed to GET, use 303 See Other instead. This is useful when you want to
|
|
249
|
+
* give an answer to a successful PUT request that is not the uploaded resource,
|
|
250
|
+
* but a status monitor or confirmation message like "You have successfully
|
|
251
|
+
* uploaded XYZ".
|
|
252
|
+
*
|
|
253
|
+
* The difference between 307 and 302 is that 307 guarantees that the client
|
|
254
|
+
* will not change the request method and body when the redirected request is
|
|
255
|
+
* made. With 302, older clients incorrectly changed the method to GET. 307 and
|
|
256
|
+
* 302 responses are identical when the request method is GET.
|
|
257
|
+
*
|
|
258
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307
|
|
259
|
+
*/
|
|
260
|
+
function temporaryRedirect(location) {
|
|
261
|
+
return transfer(307, location);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/response/unauthorized.ts
|
|
266
|
+
/**
|
|
267
|
+
* 401 Unauthorized
|
|
268
|
+
*
|
|
269
|
+
* The HTTP 401 Unauthorized client error response status code indicates that a
|
|
270
|
+
* request was not successful because it lacks valid authentication credentials
|
|
271
|
+
* for the requested resource. This status code is sent with an HTTP
|
|
272
|
+
* WWW-Authenticate response header that contains information on the
|
|
273
|
+
* authentication scheme the server expects the client to include to make the
|
|
274
|
+
* request successfully.
|
|
275
|
+
*
|
|
276
|
+
* A 401 Unauthorized is similar to the 403 Forbidden response, except that a
|
|
277
|
+
* 403 is returned when a request contains valid credentials, but the client
|
|
278
|
+
* does not have permissions to perform a certain action.
|
|
279
|
+
*
|
|
280
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401
|
|
281
|
+
*/
|
|
282
|
+
function unauthorized(body) {
|
|
283
|
+
return response(401, body ?? "Unauthorized");
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/response/unprocessable.ts
|
|
288
|
+
/**
|
|
289
|
+
* 422 Unprocessable Content
|
|
290
|
+
*
|
|
291
|
+
* The HTTP 422 Unprocessable Content client error response status code
|
|
292
|
+
* indicates that the server understood the content type of the request content,
|
|
293
|
+
* and the syntax of the request content was correct, but it was unable to
|
|
294
|
+
* process the contained instructions.
|
|
295
|
+
*
|
|
296
|
+
* Clients that receive a 422 response should expect that repeating the request
|
|
297
|
+
* without modification will fail with the same error.
|
|
298
|
+
*
|
|
299
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422
|
|
300
|
+
*/
|
|
301
|
+
function unprocessable(body) {
|
|
302
|
+
return response(422, body ?? "Unprocessable");
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
//#endregion
|
|
306
|
+
export { badRequest, created, forbidden, methodNotAllowed, notModified, permRedirect$1 as permRedirect, permRedirect as permRedirect$1, permanentRedirect, serverError, temporaryRedirect, unauthorized, unprocessable };
|
|
307
|
+
//# sourceMappingURL=response-D-XpIuMH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-D-XpIuMH.js","names":["permRedirect"],"sources":["../src/response/badRequest.ts","../src/response/created.ts","../src/response/forbidden.ts","../src/response/found.ts","../src/response/methodNotAllowed.ts","../src/response/movedPermanently.ts","../src/response/notModified.ts","../src/response/permanentRedirect.ts","../src/response/serverError.ts","../src/response/temporaryRedirect.ts","../src/response/unauthorized.ts","../src/response/unprocessable.ts"],"sourcesContent":["import response from \"./response\";\n\n/**\n * 400 Bad Request\n *\n * The HTTP 400 Bad Request client error response status code indicates that the\n * server would not process the request due to something the server considered\n * to be a client error. The reason for a 400 response is typically due to\n * malformed request syntax, invalid request message framing, or deceptive\n * request routing.\n *\n * Clients that receive a 400 response should expect that repeating the request\n * without modification will fail with the same error.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/400\n */\nexport default function badRequest(body?: object | string): Response {\n\treturn response(400, body ?? \"Bad request\");\n}\n","import response from \"./response\";\n\n/**\n * 201 Created\n *\n * The HTTP 201 Created successful response status code indicates that the HTTP\n * request has led to the creation of a resource. This status code is commonly\n * sent as the result of a POST request.\n *\n * The new resource, or a description and link to the new resource, is created\n * before the response is returned. The newly-created items can be returned in\n * the body of the response message, but must be locatable by the URL of the\n * initiating request or by the URL in the value of the Location header provided\n * with the response.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/201\n */\nexport default function created(body?: object | string): Response {\n\treturn response(201, body);\n}\n","import response from \"./response\";\n\n/**\n * 403 Forbidden\n *\n * The HTTP 403 Forbidden client error response status code indicates that the\n * server understood the request but refused to process it. This status is\n * similar to 401, except that for 403 Forbidden responses, authenticating or\n * re-authenticating makes no difference. The request failure is tied to\n * application logic, such as insufficient permissions to a resource or action.\n *\n * Clients that receive a 403 response should expect that repeating the request\n * without modification will fail with the same error. Server owners may decide\n * to send a 404 response instead of a 403 if acknowledging the existence of a\n * resource to clients with insufficient privileges is not desired.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403\n */\nexport default function forbidden(body?: object | string): Response {\n\treturn response(403, body ?? \"Forbidden\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 302 Found\n *\n * The HTTP 302 Found redirection response status code indicates that the\n * requested resource has been temporarily moved to the URL in the Location\n * header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will not attribute links to the original URL\n * to the new resource, meaning no SEO value is transferred to the new URL.\n *\n * > Note: In the Fetch Standard, when a user agent receives a 302 in response\n * > to a POST request, it uses the GET method in the subsequent redirection\n * > request, as permitted by the HTTP specification. To avoid user agents\n * > modifying the request, use 307 Temporary Redirect instead, as altering the\n * > method after a 307 response is prohibited.\n *\n * > In cases where you want any request method to be changed to GET, use 303\n * > See Other. This is useful when you want to give a response to a PUT method\n * > that is not the uploaded resource but a confirmation message such as: \"you\n * > successfully uploaded XYZ\".\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302\n */\nexport default function permRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import response from \"./response\";\n\n/**\n * 405 Method Not Allowed\n *\n * The HTTP 405 Method Not Allowed client error response status code indicates\n * that the server knows the request method, but the target resource doesn't\n * support this method. The server must generate an Allow header in a 405\n * response with a list of methods that the target resource currently supports.\n *\n * Improper server-side permissions set on files or directories may cause a 405\n * response when the request would otherwise be expected to succeed.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/405\n */\nexport default function methodNotAllowed(body?: object | string): Response {\n\treturn response(405, body ?? \"Method not allowed\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 301 Moved Permanently\n *\n * The HTTP 301 Moved Permanently redirection response status code indicates\n * that the requested resource has been permanently moved to the URL in the\n * Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will attribute links to the original URL to\n * the redirected resource, passing the SEO ranking to the new URL.\n *\n * > Note: In the Fetch Standard, when a user agent receives a 301 in response\n * > to a POST request, it uses the GET method in the subsequent redirection\n * > request, as permitted by the HTTP specification. To avoid user agents\n * > modifying the request, use 308 Permanent Redirect instead, as altering the\n * > method after a 308 response is prohibited.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301\n */\nexport default function permRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import transfer from \"./transfer\";\n\n/**\n * 304 Not Modified\n *\n * The HTTP 304 Not Modified redirection response status code indicates that\n * there is no need to retransmit the requested resources.\n *\n * This response code is sent when the request is a conditional GET or HEAD\n * request with an If-None-Match or an If-Modified-Since header and the\n * condition evaluates to 'false'. It confirms that the resource cached by the\n * client is still valid and that the server would have sent a 200 OK response\n * with the resource if the condition evaluated to 'true'. See HTTP caching for\n * more information.\n *\n * The response must not contain a body and must include the headers that would\n * have been sent in an equivalent 200 response, such as:\n *\n * - Cache-Control\n * - Content-Location\n * - Date\n * - ETag\n * - Expires\n * - Vary\n *\n * > Note: Many developer tools' network panels of browsers create extraneous\n * > requests leading to 304 responses, so that access to the local cache is\n * > visible to developers.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/304\n */\nexport default function notModified(location: string): Response {\n\treturn transfer(304, location);\n}\n","import transfer from \"./transfer\";\n\n/**\n * 308 Permanent Redirect\n *\n * The HTTP 308 Permanent Redirect redirection response status code indicates\n * that the requested resource has been permanently moved to the URL given by\n * the Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will attribute links to the original URL to\n * the redirected resource, passing the SEO ranking to the new URL.\n *\n * The request method and the body will not be modified by the client in the\n * redirected request. A 301 Moved Permanently requires the request method and\n * the body to remain unchanged when redirection is performed, but this is\n * incorrectly handled by older clients to use the GET method instead.\n *\n * > Note: Some Web applications may use the 308 Permanent Redirect in a\n * > non-standard way and for different purposes. For example, Google Drive uses\n * > a 308 Resume Incomplete response to indicate to the client when an\n * > unfinished upload has stalled. See Perform a resumable download on the\n * > Google Drive documentation for more information.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308\n */\nexport default function permanentRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import response from \"./response\";\n\n/**\n * 500 Server Error\n *\n * The HTTP 500 Internal Server Error server error response status code\n * indicates that the server encountered an unexpected condition that prevented\n * it from fulfilling the request. This error is a generic \"catch-all\" response\n * to server issues, indicating that the server cannot find a more appropriate\n * 5XX error to respond with.\n *\n * If you're a visitor seeing 500 errors on a web page, these issues require\n * investigation by server owners or administrators. There are many possible\n * causes of 500 errors, including: improper server configuration, out-of-memory\n * (OOM) issues, unhandled exceptions, improper file permissions, or other\n * complex factors. Server administrators may proactively log occurrences of\n * server error responses, like the 500 status code, with details about the\n * initiating requests to improve the stability of a service in the future.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500\n */\nexport default function serverError(body?: object | string): Response {\n\treturn response(500, body ?? \"Server error\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 307 Temporary Redirect\n *\n * The HTTP 307 Temporary Redirect redirection response status code indicates\n * that the resource requested has been temporarily moved to the URL in the\n * Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will not attribute links to the original URL\n * to the new resource, meaning no SEO value is transferred to the new URL.\n *\n * The method and the body of the original request are reused to perform the\n * redirected request. In the cases where you want the request method to be\n * changed to GET, use 303 See Other instead. This is useful when you want to\n * give an answer to a successful PUT request that is not the uploaded resource,\n * but a status monitor or confirmation message like \"You have successfully\n * uploaded XYZ\".\n *\n * The difference between 307 and 302 is that 307 guarantees that the client\n * will not change the request method and body when the redirected request is\n * made. With 302, older clients incorrectly changed the method to GET. 307 and\n * 302 responses are identical when the request method is GET.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307\n */\nexport default function temporaryRedirect(location: string): Response {\n\treturn transfer(307, location);\n}\n","import response from \"./response\";\n\n/**\n * 401 Unauthorized\n *\n * The HTTP 401 Unauthorized client error response status code indicates that a\n * request was not successful because it lacks valid authentication credentials\n * for the requested resource. This status code is sent with an HTTP\n * WWW-Authenticate response header that contains information on the\n * authentication scheme the server expects the client to include to make the\n * request successfully.\n *\n * A 401 Unauthorized is similar to the 403 Forbidden response, except that a\n * 403 is returned when a request contains valid credentials, but the client\n * does not have permissions to perform a certain action.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401\n */\nexport default function unauthorized(body?: object | string): Response {\n\treturn response(401, body ?? \"Unauthorized\");\n}\n","import response from \"./response\";\n\n/**\n * 422 Unprocessable Content\n *\n * The HTTP 422 Unprocessable Content client error response status code\n * indicates that the server understood the content type of the request content,\n * and the syntax of the request content was correct, but it was unable to\n * process the contained instructions.\n *\n * Clients that receive a 422 response should expect that repeating the request\n * without modification will fail with the same error.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422\n */\nexport default function unprocessable(body?: object | string): Response {\n\treturn response(422, body ?? \"Unprocessable\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAwB,WAAW,MAAkC;AACpE,QAAO,SAAS,KAAK,QAAQ,cAAc;;;;;;;;;;;;;;;;;;;;ACA5C,SAAwB,QAAQ,MAAkC;AACjE,QAAO,SAAS,KAAK,KAAK;;;;;;;;;;;;;;;;;;;;;ACA3B,SAAwB,UAAU,MAAkC;AACnE,QAAO,SAAS,KAAK,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQ1C,SAAwB,aAAa,UAA4B;AAChE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;ACb/B,SAAwB,iBAAiB,MAAkC;AAC1E,QAAO,SAAS,KAAK,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;ACMnD,SAAwBA,eAAa,UAA4B;AAChE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQ/B,SAAwB,YAAY,UAA4B;AAC/D,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACL/B,SAAwB,kBAAkB,UAA4B;AACrE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;ACP/B,SAAwB,YAAY,MAAkC;AACrE,QAAO,SAAS,KAAK,QAAQ,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACM7C,SAAwB,kBAAkB,UAA4B;AACrE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;ACX/B,SAAwB,aAAa,MAAkC;AACtE,QAAO,SAAS,KAAK,QAAQ,eAAe;;;;;;;;;;;;;;;;;;ACJ7C,SAAwB,cAAc,MAAkC;AACvE,QAAO,SAAS,KAAK,QAAQ,gBAAgB"}
|