backend/index.js

42 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-03-03 16:44:40 +00:00
require('dotenv').config()
const express = require('express')
const cors = require('cors')
const logger = require('./utils/logger.js')
const latestController = require('./controller/latest.js')
const videoController = require('./controller/video.js')
const searchController = require('./controller/search.js')
const websocketController = require('./controller/websocket.js')
const transparencyController = require('./controller/transparency.js')
const app = express()
require('express-ws')(app)
app.use(cors())
app.get('/latest', latestController.getLatest)
app.get('/video/:id', videoController.getVideo)
app.get('/channel/:id', videoController.getChannel)
app.get('/playlist/:id', videoController.getPlaylist)
app.get('/search/video', searchController.searchVideo)
app.get('/search/playlist', searchController.searchPlaylist)
app.get('/search/channel', searchController.searchChannel)
app.get('/transparency/list', transparencyController.getReports)
app.get('/transparency/:id', transparencyController.getReport)
app.ws('/save', websocketController.save)
app.ws('/saveplaylist', websocketController.playlist)
app.ws('/savechannel', websocketController.channel)
app.get('/autodownload', websocketController.addAutodownload)
2023-03-28 14:53:11 +00:00
process.on('uncaughtException', err => {
logger.error(err)
2023-03-28 14:53:11 +00:00
})
2023-03-03 18:56:50 +00:00
2023-03-03 16:44:40 +00:00
app.listen(1337, () => {
logger.info({ message: 'Server listening on port 1337!' })
})