-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin.ts
More file actions
26 lines (22 loc) · 738 Bytes
/
plugin.ts
File metadata and controls
26 lines (22 loc) · 738 Bytes
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
// I don't know why this can't be a module, but whatever...
const express = require('express');
const app = express();
const { getVideoInformation, getRandomVideos } = require('./util/yt.js');
app.get('/mcas', async (req, res) => {
if ('v' in req.query) {
const videos = await getVideoInformation(...req.query.v.split(';'));
res.send(JSON.stringify(videos));
}
if ('random_videos' in req.query) {
const videos = await getRandomVideos(Number(req.query.random_videos));
res.send(JSON.stringify(videos));
}
});
module.exports = function mcas() {
return {
name: 'mcas-vite-plugin',
configureServer(server) {
server.middlewares.use(app);
},
};
};