@trenskow/app 0.9.4 → 0.9.6
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/lib/endpoint.js +2 -0
- package/package.json +1 -1
- package/test/index.js +19 -0
package/lib/endpoint.js
CHANGED
|
@@ -204,6 +204,8 @@ export default class Endpoint extends Router {
|
|
|
204
204
|
if (methods.length) {
|
|
205
205
|
context.response.headers.allow = methods.map((method) => method.toUpperCase()).join(', ');
|
|
206
206
|
throw new ApiError.MethodNotAllowed();
|
|
207
|
+
} else {
|
|
208
|
+
throw new ApiError.NotFound();
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
} else {
|
package/package.json
CHANGED
package/test/index.js
CHANGED
|
@@ -195,6 +195,25 @@ describe('Application', () => {
|
|
|
195
195
|
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
+
it ('should respond with 404 when endpoint has no methods.', async () => {
|
|
199
|
+
|
|
200
|
+
app.root(
|
|
201
|
+
new Endpoint()
|
|
202
|
+
.mounts.hello(
|
|
203
|
+
new Endpoint()
|
|
204
|
+
.mounts.world(
|
|
205
|
+
new Endpoint()
|
|
206
|
+
.get(() => 'Hello, World!')
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
await request
|
|
212
|
+
.get('/hello')
|
|
213
|
+
.expect(404);
|
|
214
|
+
|
|
215
|
+
});
|
|
216
|
+
|
|
198
217
|
it ('should respond with parameter value.', async () => {
|
|
199
218
|
|
|
200
219
|
app.root(
|