]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/controllers/api/index.ts
Add new plugin/peertube version notifs
[github/Chocobozzz/PeerTube.git] / server / controllers / api / index.ts
... / ...
CommitLineData
1import * as cors from 'cors'
2import * as express from 'express'
3import * as RateLimit from 'express-rate-limit'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
5import { badRequest } from '../../helpers/express-utils'
6import { CONFIG } from '../../initializers/config'
7import { abuseRouter } from './abuse'
8import { accountsRouter } from './accounts'
9import { bulkRouter } from './bulk'
10import { configRouter } from './config'
11import { jobsRouter } from './jobs'
12import { oauthClientsRouter } from './oauth-clients'
13import { overviewsRouter } from './overviews'
14import { pluginRouter } from './plugins'
15import { searchRouter } from './search'
16import { serverRouter } from './server'
17import { usersRouter } from './users'
18import { videoChannelRouter } from './video-channel'
19import { videoPlaylistRouter } from './video-playlist'
20import { videosRouter } from './videos'
21
22const apiRouter = express.Router()
23
24apiRouter.use(cors({
25 origin: '*',
26 exposedHeaders: 'Retry-After',
27 credentials: true
28}))
29
30const apiRateLimiter = RateLimit({
31 windowMs: CONFIG.RATES_LIMIT.API.WINDOW_MS,
32 max: CONFIG.RATES_LIMIT.API.MAX
33})
34apiRouter.use(apiRateLimiter)
35
36apiRouter.use('/server', serverRouter)
37apiRouter.use('/abuses', abuseRouter)
38apiRouter.use('/bulk', bulkRouter)
39apiRouter.use('/oauth-clients', oauthClientsRouter)
40apiRouter.use('/config', configRouter)
41apiRouter.use('/users', usersRouter)
42apiRouter.use('/accounts', accountsRouter)
43apiRouter.use('/video-channels', videoChannelRouter)
44apiRouter.use('/video-playlists', videoPlaylistRouter)
45apiRouter.use('/videos', videosRouter)
46apiRouter.use('/jobs', jobsRouter)
47apiRouter.use('/search', searchRouter)
48apiRouter.use('/overviews', overviewsRouter)
49apiRouter.use('/plugins', pluginRouter)
50apiRouter.use('/ping', pong)
51apiRouter.use('/*', badRequest)
52
53// ---------------------------------------------------------------------------
54
55export { apiRouter }
56
57// ---------------------------------------------------------------------------
58
59function pong (req: express.Request, res: express.Response) {
60 return res.send('pong').status(HttpStatusCode.OK_200).end()
61}