Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get video with tag #52

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/api/v1/post.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as express from 'express';
import { Video } from '../../model/index';
import { Tag, Video } from '../../model/index';
import tagService from '../../service/tagService';
import postValidation from '../../validation/postValidation';
import { Op } from 'sequelize';

const router = express.Router();

// get video
router.get('/video/:postId', async (request: express.Request, response: express.Response) => {
const postId = Number(request.params.postId);
if(isNaN(postId)) {
router.get('/video/:videoId', async (request: express.Request, response: express.Response) => {
const videoId = Number(request.params.videoId);
if(isNaN(videoId)) {
response.status(400).json({
error: {
message: 'invalid_id',
Expand All @@ -19,7 +19,11 @@ router.get('/video/:postId', async (request: express.Request, response: express.
return;
}

const video = await Video.findByPk(postId);
const video = await Video.findByPk(videoId, {
include: {
model: Tag,
}
});
if(video == null) {
response.status(400).json({
error: {
Expand Down