@stanlemon/server-with-auth 0.3.37 → 0.4.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.
Files changed (3) hide show
  1. package/app.js +1 -1
  2. package/app.test.js +24 -3
  3. package/package.json +1 -1
package/app.js CHANGED
@@ -53,4 +53,4 @@ app.get(
53
53
  }))
54
54
  );
55
55
 
56
- app.catch404s("/api/*");
56
+ app.catch404s("/api/");
package/app.test.js CHANGED
@@ -5,9 +5,6 @@ import request from "supertest";
5
5
  import { app } from "./app.js";
6
6
  import { signupAndLogin } from "./src/utilities/testUtils.js";
7
7
 
8
- const username = "test" + Math.random();
9
- const password = "p@$$w0rd!";
10
-
11
8
  describe("/app", () => {
12
9
  it("Insecure endpoint", async () => {
13
10
  // Insecure endpoint
@@ -29,6 +26,7 @@ describe("/app", () => {
29
26
  });
30
27
 
31
28
  it("Secure endpoint with auth", async () => {
29
+ const { username, password } = makeUsernameAndPassword();
32
30
  const session = await signupAndLogin(app, username, password, {
33
31
  email: "test@test.com",
34
32
  fullName: "Test User",
@@ -50,4 +48,27 @@ describe("/app", () => {
50
48
  })
51
49
  );
52
50
  });
51
+
52
+ it("404 on undefined api path", async () => {
53
+ const { username, password } = makeUsernameAndPassword();
54
+ const session = await signupAndLogin(app, username, password, {
55
+ email: "test@test.com",
56
+ fullName: "Test User",
57
+ });
58
+
59
+ const token = session.token;
60
+
61
+ const response = await request(app)
62
+ .get("/api/not-found")
63
+ .set("Accept", "application/json")
64
+ .set("Authorization", "Bearer " + token);
65
+
66
+ expect(response.status).toEqual(404);
67
+ });
53
68
  });
69
+
70
+ function makeUsernameAndPassword() {
71
+ const username = "test" + Math.random();
72
+ const password = "p@$$w0rd!";
73
+ return { username, password };
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stanlemon/server-with-auth",
3
- "version": "0.3.37",
3
+ "version": "0.4.0",
4
4
  "description": "A basic express web server setup with authentication baked in.",
5
5
  "author": "Stan Lemon <stanlemon@users.noreply.github.com>",
6
6
  "license": "MIT",