]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/static.ts
Disable sql prettifier by default
[github/Chocobozzz/PeerTube.git] / server / controllers / static.ts
index ff77452ddb838f58b8714d43a48aa96ab795e0c8..a7b28704ca4c2569bb33c31980276bb1db3e72d7 100644 (file)
@@ -19,14 +19,16 @@ import { VideoCommentModel } from '../models/video/video-comment'
 import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo'
 import { join } from 'path'
 import { root } from '../helpers/core-utils'
+import { getEnabledResolutions } from '../lib/video-transcoding'
 import { CONFIG, isEmailEnabled } from '../initializers/config'
 import { getPreview, getVideoCaption } from './lazy-static'
 import { VideoStreamingPlaylistType } from '@shared/models/videos/video-streaming-playlist.type'
 import { MVideoFile, MVideoFullLight } from '@server/types/models'
 import { getTorrentFilePath, getVideoFilePath } from '@server/lib/video-paths'
 import { getThemeOrDefault } from '../lib/plugins/theme-utils'
-import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config'
+import { getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config'
 import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { serveIndexHTML } from '@server/lib/client-html'
 
 const staticRouter = express.Router()
 
@@ -119,6 +121,11 @@ staticRouter.get('/robots.txt',
   }
 )
 
+staticRouter.all('/teapot',
+  getCup,
+  asyncMiddleware(serveIndexHTML)
+)
+
 // security.txt service
 staticRouter.get('/security.txt',
   (_, res: express.Response) => {
@@ -200,7 +207,7 @@ export {
 async function generateNodeinfo (req: express.Request, res: express.Response) {
   const { totalVideos } = await VideoModel.getStats()
   const { totalLocalVideoComments } = await VideoCommentModel.getStats()
-  const { totalUsers } = await UserModel.getStats()
+  const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats()
   let json = {}
 
   if (req.params.version && (req.params.version === '2.0')) {
@@ -223,7 +230,9 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
       openRegistrations: CONFIG.SIGNUP.ENABLED,
       usage: {
         users: {
-          total: totalUsers
+          total: totalUsers,
+          activeMonth: totalMonthlyActiveUsers,
+          activeHalfyear: totalHalfYearActiveUsers
         },
         localPosts: totalVideos,
         localComments: totalLocalVideoComments
@@ -391,3 +400,11 @@ function getHLSPlaylist (video: MVideoFullLight) {
 
   return Object.assign(playlist, { Video: video })
 }
+
+function getCup (req: express.Request, res: express.Response, next: express.NextFunction) {
+  res.status(HttpStatusCode.I_AM_A_TEAPOT_418)
+  res.setHeader('Accept-Additions', 'Non-Dairy;1,Sugar;1')
+  res.setHeader('Safe', 'if-sepia-awake')
+
+  return next()
+}