Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed Jan 10, 2022
1 parent 3d6f6ee commit 76e18ef
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 48 deletions.
93 changes: 59 additions & 34 deletions api/src/router/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,84 +1,109 @@
import express from "express";
import { verifyRequest } from "src/middlewares"
import { verifyRequest } from "src/middlewares";
import * as controller from "./controller";
import * as validators from "./validators";

const user = express();

// Get and create user(s)
user.get("/users", controller.getAllUsers);
user.post("/users", verifyRequest, validators.createUser, controller.createUser);
user.post(
"/users",
verifyRequest,
validators.createUser,
controller.createUser
);
user.get("/users/:id", validators.getUser, controller.getUser); // User dwolla info
user.get("/users/email/:email", controller.getUserByEmail); // User database info

// Get and create deposit(s) for a user
user.get("/users/:id/deposit", validators.getUser, controller.getDeposits);
user.post("/users/:id/deposit", verifyRequest,validators.deposit, controller.deposit);
user.post(
"/users/:id/deposit",
verifyRequest,
validators.deposit,
controller.deposit
);

// Get and create withdrawal(s) for a user
user.get("/users/:id/withdraw", validators.getUser, controller.getWithdrawals);
user.post("/users/:id/withdraw", verifyRequest,validators.withdraw, controller.withdraw);
user.post(
"/users/:id/withdraw",
verifyRequest,
validators.withdraw,
controller.withdraw
);

// Get and create transfer(s) for a user
user.get("/users/:id/transfer", validators.getUser, controller.getTransfers);
user.post("/users/:id/transfer", verifyRequest, validators.transfer, controller.transferTo);
user.post(
"/users/:id/transfer",
verifyRequest,
validators.transfer,
controller.transferTo
);

// Get Dwolla iav-token for a user (via POST)
user.post("/users/:id/iav-token", verifyRequest, validators.getUser, controller.getIAVToken);
user.post(
"/users/:id/iav-token",
verifyRequest,
validators.getUser,
controller.getIAVToken
);

// Get funding sources for a user
user.get(
"/users/:id/funding-sources",
verifyRequest,
validators.getUser,
controller.getFundingSources
"/users/:id/funding-sources",
verifyRequest,
validators.getUser,
controller.getFundingSources
);

// Get and close notifications for a user
user.get(
"/users/:id/notifications",
verifyRequest,
validators.getUser,
controller.getNotifications
"/users/:id/notifications",
verifyRequest,
validators.getUser,
controller.getNotifications
);

user.delete(
"/users/:id/notifications/:notificationId",
verifyRequest,
validators.notifications,
controller.closeNotification
"/users/:id/notifications/:notificationId",
verifyRequest,
validators.notifications,
controller.closeNotification
);

// Add Customer account to existing Business account
user.post(
"/users/:id/customer",
verifyRequest,
validators.addCustomer,
controller.addCustomer
"/users/:id/customer",
verifyRequest,
validators.addCustomer,
controller.addCustomer
);

// Add Business account to existing Customer account
user.post(
"/users/:id/business",
verifyRequest,
validators.addBusiness,
controller.addBusiness
"/users/:id/business",
verifyRequest,
validators.addBusiness,
controller.addBusiness
);

// Update existing Customer Account
user.put(
"/users/:id/customer/profile",
verifyRequest,
validators.updateCustomerProfile,
controller.updateCustomerProfile
"/users/:id/customer/profile",
verifyRequest,
validators.updateCustomerProfile,
controller.updateCustomerProfile
);

// Update existing Business Account
user.put(
"/users/:id/business/profile",
verifyRequest,
validators.updateBusinessProfile,
controller.updateBusinessProfile
"/users/:id/business/profile",
verifyRequest,
validators.updateBusinessProfile,
controller.updateBusinessProfile
);

export default user;
17 changes: 3 additions & 14 deletions api/src/router/user/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,11 @@ export const createUser = [
mwVaildator,
];

export const notifications = [
...idInParams,
...notificationIdInParams,
];
export const notifications = [...idInParams, ...notificationIdInParams];

export const getUser = [...idInParams];

export const deposit = [
...idInParams,
body("amount").isString(),
mwVaildator,
];
export const deposit = [...idInParams, body("amount").isString(), mwVaildator];

export const addCustomer = [
...idInParams,
Expand Down Expand Up @@ -117,11 +110,7 @@ export const addBusiness = [
mwVaildator,
];

export const withdraw = [
...idInParams,
body("amount").isString(),
mwVaildator,
];
export const withdraw = [...idInParams, body("amount").isString(), mwVaildator];

export const transfer = [
...idInParams,
Expand Down

0 comments on commit 76e18ef

Please sign in to comment.