Skip to content

Commit

Permalink
fix: use Joi to limit subwallet creation
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiyuSun committed Jul 14, 2023
1 parent 14a1b45 commit b8b8f51
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/routes/walletRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const express = require('express');

const router = express.Router();
const routerWrapper = express.Router();
const Joi = require("joi");
const {
handlerWrapper,
verifyJWTHandler,
Expand All @@ -22,7 +23,13 @@ router.get(
'/:wallet_id/trust_relationships',
handlerWrapper(walletGetTrustRelationships),
);
router.post('/', handlerWrapper(walletPost));
router.post('/', handlerWrapper(async (req, res) => {
Joi.assert(req.body, Joi.object({
wallet: Joi.string().min(3).max(20).trim(true)
}))
await walletPost(req, res);
}));


routerWrapper.use('/wallets', apiKeyHandler, verifyJWTHandler, router);
module.exports = routerWrapper;

0 comments on commit b8b8f51

Please sign in to comment.