1
0
Fork 0
mirror of https://codeberg.org/ashley/poke.git synced 2024-11-17 00:14:39 -05:00
poke/server.js

111 lines
2.8 KiB
JavaScript
Raw Normal View History

2022-09-21 02:36:21 -04:00
/*
2022-07-29 08:26:00 -04:00
PokeTube is an Free/Libre youtube front-end. this is our main file.
2022-05-17 16:18:32 -04:00
Copyright (C) 2021-2022 POKETUBE (https://github.com/iamashley0/poketube)
2022-02-28 12:33:58 -05:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
*/
2022-11-06 06:09:28 -05:00
2022-11-08 10:35:38 -05:00
const {
fetcher,
core,
wiki,
musicInfo,
modules,
2022-11-09 09:27:56 -05:00
version,
initlog,
init,
} = require("./src/libpoketube/libpoketube-initsys.js");
2022-11-09 11:46:37 -05:00
const { sinit } = require("./src/libpoketube/init/superinit.js");
2022-11-09 09:27:56 -05:00
initlog("Loading...");
initlog(
"[Welcome] Welcome To PokeTube :3 " +
"Running " +
`Node ${process.version} - V8 v${
process.versions.v8
} - ${process.platform.replace("linux", "GNU/Linux")} ${
process.arch
} Server - libpt ${version}`
);
2022-11-08 10:35:38 -05:00
const {
IsJsonString,
convert,
getFirstLine,
capitalizeFirstLetter,
turntomins,
getRandomInt,
getRandomArbitrary,
} = require("./src/libpoketube/ptutils/libpt-coreutils.js");
2022-11-06 06:09:28 -05:00
2022-11-09 09:27:56 -05:00
initlog("Loaded libpt-coreutils");
2022-11-06 06:09:28 -05:00
const templateDir = modules.path.resolve(
`${process.cwd()}${modules.path.sep}html`
);
2022-10-09 06:34:39 -04:00
2022-11-06 06:09:28 -05:00
const sha384 = modules.hash;
2022-07-25 07:45:34 -04:00
2022-10-29 03:50:39 -04:00
var app = modules.express();
2022-11-09 09:27:56 -05:00
initlog("Loaded express.js");
2021-07-07 08:35:33 -04:00
app.engine("html", require("ejs").renderFile);
2022-10-29 03:50:39 -04:00
app.use(modules.express.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.use(modules.useragent.express());
2022-06-26 04:24:02 -04:00
2021-07-07 08:35:33 -04:00
app.set("view engine", "html");
2022-10-29 03:50:39 -04:00
2022-02-23 13:54:21 -05:00
const renderTemplate = async (res, req, template, data = {}) => {
res.render(
2022-10-29 03:50:39 -04:00
modules.path.resolve(`${templateDir}${modules.path.sep}${template}`),
2022-02-23 13:54:21 -05:00
Object.assign(data)
);
2021-07-07 08:35:33 -04:00
};
2022-07-13 08:35:18 -04:00
2022-03-11 15:52:04 -05:00
const random_words = [
"banana pie",
"how to buy an atom bomb",
"is love just an illusion",
"things to do if ur face becomes benjamin frenklin",
"how do defeat an pasta",
"can you go to space?",
"how to become a god?",
"is a panda a panda if pandas???",
"Minecraft movie trailer",
2022-09-21 02:36:21 -04:00
"monke",
];
2022-07-12 13:06:02 -04:00
2022-06-26 04:24:02 -04:00
/*
this is our config file,you can change stuff here
*/
const config = {
tubeApi: "https://tube.kuylar.dev/api/",
2022-10-27 11:42:38 -04:00
invapi: "https://inv.vern.cc/api/v1",
dislikes: "https://returnyoutubedislikeapi.com/votes?videoId=",
t_url: "https://t.poketube.fun/", // def matomo url
};
2022-06-26 04:24:02 -04:00
2022-09-21 02:36:21 -04:00
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
2022-08-23 08:04:34 -04:00
2022-09-21 02:36:21 -04:00
next();
});
2022-09-17 12:22:47 -04:00
2022-11-14 11:33:55 -05:00
sinit(app, config, renderTemplate);
2022-09-21 02:36:21 -04:00
2022-11-09 09:27:56 -05:00
init(app);
2022-11-14 11:33:55 -05:00