-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from neet/channel
chore: Add channel
- Loading branch information
Showing
112 changed files
with
1,419 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ | |
"sqltag", | ||
"storyshots", | ||
"tailwindcss", | ||
"Twicasting", | ||
"unfetch", | ||
"unmount", | ||
"unoptimized", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/@neet/vschedule-api-spec/src/components/parameters/PathChannelId.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { z } from 'zod'; | ||
|
||
import { registry } from '../../api'; | ||
|
||
export const PathChannelId = registry.registerParameter( | ||
'PathChannelId', | ||
z.string().openapi({ param: { name: 'channelId', in: 'path' } }), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/@neet/vschedule-api-spec/src/components/schemas/Channel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { z } from 'zod'; | ||
|
||
import { registry } from '../../api'; | ||
|
||
export const BaseChannel = registry.register( | ||
'BaseChannel', | ||
z.object({ | ||
id: z.string(), | ||
name: z.string(), | ||
description: z.string().nullish(), | ||
}), | ||
); | ||
|
||
export const YoutubeChannel = registry.register( | ||
'YoutubeChannel', | ||
BaseChannel.extend({ | ||
type: z.literal('youtube'), | ||
url: z.string().url(), | ||
}), | ||
); | ||
|
||
export const TwitchChannel = registry.register( | ||
'TwitchChannel', | ||
BaseChannel.extend({ | ||
type: z.literal('twitch'), | ||
url: z.string().url(), | ||
}), | ||
); | ||
|
||
export const TwicastingChannel = registry.register( | ||
'TwicastingChannel', | ||
BaseChannel.extend({ | ||
type: z.literal('twicasting'), | ||
url: z.string().url(), | ||
}), | ||
); | ||
|
||
export const Channel = registry.register( | ||
'Channel', | ||
z.discriminatedUnion('type', [ | ||
YoutubeChannel, | ||
TwitchChannel, | ||
TwicastingChannel, | ||
]), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/@neet/vschedule-api-spec/src/paths/rest/v1/channels.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { z } from 'zod'; | ||
|
||
import { registry } from '../../../api'; | ||
import { PathChannelId } from '../../../components/parameters/PathChannelId'; | ||
|
||
registry.registerPath({ | ||
method: 'post', | ||
path: '/rest/v1/channels/{channelId}/subscribe', | ||
operationId: 'subscribeToChannel', | ||
summary: 'チャンネルを購読', | ||
request: { | ||
params: z.object({ | ||
channelId: PathChannelId, | ||
}), | ||
}, | ||
responses: { | ||
200: { | ||
description: '成功時のレスポンスです', | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/@neet/vschedule-api/prisma/migrations/20221122200952_add_channel/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Warnings: | ||
- Added the required column `channel_id` to the `streams` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE `streams` ADD COLUMN `channel_id` VARCHAR(191) NOT NULL; | ||
|
||
-- CreateTable | ||
CREATE TABLE `channels` ( | ||
`id` VARCHAR(21) NOT NULL, | ||
`name` VARCHAR(191) NOT NULL, | ||
`status` VARCHAR(191) NOT NULL, | ||
`description` TEXT NULL, | ||
`performer_id` VARCHAR(191) NULL, | ||
`organization_id` VARCHAR(191) NULL, | ||
|
||
INDEX `channels_performer_id_organization_id_idx`(`performer_id`, `organization_id`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `youtube_channels` ( | ||
`id` VARCHAR(21) NOT NULL, | ||
`youtubeChannelId` VARCHAR(191) NOT NULL, | ||
|
||
UNIQUE INDEX `youtube_channels_youtubeChannelId_key`(`youtubeChannelId`), | ||
INDEX `youtube_channels_youtubeChannelId_idx`(`youtubeChannelId`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `streams` ADD CONSTRAINT `streams_channel_id_fkey` FOREIGN KEY (`channel_id`) REFERENCES `channels`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `channels` ADD CONSTRAINT `channels_performer_id_fkey` FOREIGN KEY (`performer_id`) REFERENCES `performers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `channels` ADD CONSTRAINT `channels_organization_id_fkey` FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `youtube_channels` ADD CONSTRAINT `youtube_channels_id_fkey` FOREIGN KEY (`id`) REFERENCES `channels`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/@neet/vschedule-api/src/adapters/controllers/rest/v1/channels.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { inject, injectable } from 'inversify'; | ||
import { JsonController, OnUndefined, Param, Post } from 'routing-controllers'; | ||
|
||
import { RequestChannelSubscription } from '../../../../app/channel/request-channel-subscription'; | ||
|
||
@injectable() | ||
@JsonController('/rest/v1/channels') | ||
export class ChannelController { | ||
constructor( | ||
@inject(RequestChannelSubscription) | ||
private readonly requestChannelSubscription: RequestChannelSubscription, | ||
) {} | ||
|
||
@Post('/:channelId/subscribe') | ||
@OnUndefined(202) | ||
async subscribe(@Param('channelId') channelId: string): Promise<void> { | ||
await this.requestChannelSubscription.invoke({ channelId }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
cff170f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
vschedule – ./
vschedule-git-main-neet.vercel.app
refined-itsukara-link.vercel.app
refined-itsukara-link.neet.love
vschedule-neet.vercel.app