@prisma/client#Room TypeScript Examples
The following examples show how to use
@prisma/client#Room.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: middleware.ts From frames with Mozilla Public License 2.0 | 4 votes |
/**
* @desc creates the SEO data for the page
* @param type - type of the page
* @param value - value of the page
*/
public async getMetaTags(type: string, value: string) {
if (type === 'movie' || type === 'show') {
const {data} = await this.supabase
.from<Modify<Media, {release: string}>>('Media')
.select('*')
.eq('type', type.toUpperCase())
.ilike('name', `*${value}*`)
if (data) {
const response = data.map(item => {
const year = new Date(item.release).getFullYear();
const drift = item.name.Levenshtein(value);
return {...item, year, drift};
})
const info = this.sortArray(response, ['drift', 'year'], ['asc', 'desc'])[0];
if (info)
return {
overview: info.overview,
name: info.name,
poster: info.poster
}
}
}
if (type === 'watch' || type === 'frame' || type === 'room') {
if (type === 'room') {
const {data} = await this.supabase
.from<Room>('Room')
.select('*')
.eq('roomKey', value)
.single();
value = data ? data.auth: value;
}
if (type === 'frame') {
const {data} = await this.supabase
.from<Frame>('Frame')
.select('*')
.eq('cypher', value)
.single();
value = data ? data.auth: value;
}
const {data} = await this.supabase
.from<(View & {episode: Episode | null, video: (Video & {media: Media})})>('View')
.select('*, episode:Episode(*), video:Video(*, media:Media!Video_mediaId_fkey(*))')
.eq('auth', value)
.single();
if (data) {
const {episode, video} = data;
let {name, overview, poster, tmdbId} = video.media;
if (episode) {
const episodeInfo = await this.getEpisode(tmdbId, episode.seasonId, episode.episode);
name = /^Episode \d+/i.test(episodeInfo?.name || 'Episode') ? `${name}: S${episode.seasonId}, E${episode.episode}` : `S${episode.seasonId}, E${episode.episode}: ${episodeInfo?.name}`;
overview = episodeInfo?.overview || overview;
}
return {
overview,
name,
poster
}
}
}
if (type === 'person') {
const person = await this.findPerson(value);
if (person)
return {
overview: `See all media produced by ${person.name} available on Frames`,
name: person.name,
poster: 'https://image.tmdb.org/t/p/original' + person.profile_path
}
}
/*if (type === 'collection') {
const {data} = await this.supabase
.from('Media')
.select('name, poster, overview, cName:collection->>name')
.ilike('cName', `*${value}*`)
.single();
console.log(data);
}*/
return {
overview: 'Frames is a streaming service that offers a wide variety of TV shows, movies, anime, documentaries, and more on thousands straight to your browser',
name: 'Frames - Watch FREE TV Shows and Movies Online',
poster: '/meta.png'
}
}