Skip to content

Commit

Permalink
feat: add route token by id
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrelstan committed Feb 1, 2022
1 parent a533643 commit dd73c73
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions server/routers/tokensRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import express from 'express';
import Joi from 'joi';
import { handlerWrapper } from './utils';
import Session from '../infra/database/Session';
import TokensRepository from '../infra/database/TokensRepository';
import TokensModel from '../models/tokens';

const router = express.Router();

router.get(
'/:tokenId',
handlerWrapper(async (req, res) => {
Joi.assert(req.params.tokenId, Joi.number().required());
const repo = new TokensRepository(new Session());
const exe = TokensModel.getById(repo);
const result = await exe(req.params.tokenId);
res.send(result);
res.end();
}),
);

0 comments on commit dd73c73

Please sign in to comment.