This repository was archived by the owner on Feb 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.ts
More file actions
57 lines (50 loc) · 3.27 KB
/
Copy pathrouter.ts
File metadata and controls
57 lines (50 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { FastifyPluginOptions } from 'fastify';
import authorization from '@/middleware/authorization';
// Route Imports:
import watch, { validation as watchVal } from '@/routes/watch';
import search, { validation as searchVal } from '@/routes/search';
import profile, { validation as profileVal } from '@/routes/profile';
import { discord, discordCallback, discordVal } from '@/routes/user/integrations';
import { info, order, recent, trending, infoVal, orderVal } from '@/routes/info';
import { check, login, register, checkVal, loginVal, registerVal } from '@/routes/auth';
import {
user,
progress,
watchlist,
bioUpdate,
userUpdate,
playerUpdate,
configUpdate,
designUpdate,
watchlistUpdate,
progressVal,
bioUpdateVal,
userUpdateVal,
playerUpdateVal,
configUpdateVal,
designUpdateVal,
watchlistUpdateVal
} from '@/routes/user';
export default async (route: Instance, opts: FastifyPluginOptions) => {
route.post('/auth/login', { preValidation: loginVal }, (req, res) => login(route, req, res));
route.post('/auth/check', { preValidation: checkVal }, (req, res) => check(route, req, res));
route.post('/auth/register', { preValidation: registerVal }, (req, res) => register(route, req, res));
route.get('/user', { preHandler: authorization }, (req, res) => user(route, req, res));
route.post('/user', { preHandler: authorization, preValidation: userUpdateVal }, (req, res) => userUpdate(route, req, res));
route.post('/user/player', { preHandler: authorization, preValidation: playerUpdateVal }, (req, res) => playerUpdate(route, req, res));
route.post('/user/progress', { preHandler: authorization, preValidation: progressVal }, (req, res) => progress(route, req, res));
route.get('/user/watchlist', { preHandler: authorization }, (req, res) => watchlist(route, req, res));
route.put('/user/watchlist', { preHandler: authorization, preValidation: watchlistUpdateVal }, (req, res) => watchlistUpdate(route, req, res));
route.get('/user/profile/:user', { preValidation: profileVal }, (req, res) => profile(route, req, res));
route.post('/user/profile/bio', { preHandler: authorization, preValidation: bioUpdateVal }, (req, res) => bioUpdate(route, req, res));
route.post('/user/profile/config', { preHandler: authorization, preValidation: configUpdateVal }, (req, res) => configUpdate(route, req, res));
route.post('/user/profile/design', { preHandler: authorization, preValidation: designUpdateVal }, (req, res) => designUpdate(route, req, res));
route.get('/user/integrations/discord', (req, res) => discord(route, req, res));
route.post('/user/integrations/discord', { preValidation: discordVal }, (req, res) => discordCallback(route, req, res));
route.get('/info/recent', (req, res) => recent(route, req, res));
route.get('/info/trending', (req, res) => trending(route, req, res));
route.get('/info/:id', { preValidation: infoVal }, (req, res) => info(route, req, res));
route.get('/info/:id/order', { preValidation: orderVal }, (req, res) => order(route, req, res));
route.get('/search', { preValidation: searchVal }, (req, res) => search(route, req, res));
route.get('/watch/:anime/:ep', { preHandler: authorization, preValidation: watchVal }, (req, res) => watch(route, req, res));
};