Skip to content

Commit

Permalink
backend: enable API token for contact routes
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed Jul 13, 2024
1 parent 53d3357 commit 45e8339
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions backend/src/routes/contactRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import isAuth from "../middleware/isAuth";

import * as ContactController from "../controllers/ContactController";
import * as ImportPhoneContactsController from "../controllers/ImportPhoneContactsController";
import apiTokenAuth from "../middleware/apiTokenAuth";

const contactRoutes = express.Router();

Expand All @@ -12,16 +13,36 @@ contactRoutes.post(
ImportPhoneContactsController.store
);

contactRoutes.get("/contacts", isAuth, ContactController.index);
contactRoutes.get("/contacts", apiTokenAuth, isAuth, ContactController.index);

contactRoutes.get("/contacts/list", isAuth, ContactController.list);
contactRoutes.get(
"/contacts/list",
apiTokenAuth,
isAuth,
ContactController.list
);

contactRoutes.get("/contacts/:contactId", isAuth, ContactController.show);
contactRoutes.get(
"/contacts/:contactId",
apiTokenAuth,
isAuth,
ContactController.show
);

contactRoutes.post("/contacts", isAuth, ContactController.store);
contactRoutes.post("/contacts", apiTokenAuth, isAuth, ContactController.store);

contactRoutes.put("/contacts/:contactId", isAuth, ContactController.update);
contactRoutes.put(
"/contacts/:contactId",
apiTokenAuth,
isAuth,
ContactController.update
);

contactRoutes.delete("/contacts/:contactId", isAuth, ContactController.remove);
contactRoutes.delete(
"/contacts/:contactId",
apiTokenAuth,
isAuth,
ContactController.remove
);

export default contactRoutes;

0 comments on commit 45e8339

Please sign in to comment.