Compare commits

...

20 Commits

Author SHA1 Message Date
f8a9d37221 Merge pull request 'fix start.sh' (#8) from dev into main
Reviewed-on: #8
2026-01-19 16:11:47 -05:00
de24f5488e fix start.sh 2026-01-19 16:11:31 -05:00
3d0c93fbef Merge pull request 'load ytmusic stuffs from cache and add dev logging' (#7) from dev into main
Reviewed-on: #7
2026-01-19 16:09:18 -05:00
85279ecc47 make req logging less verbose 2026-01-19 16:06:54 -05:00
c9d7afd353 add verbose logging to dev server 2026-01-19 15:33:22 -05:00
669231e8a6 actually load from cache 2026-01-19 14:57:08 -05:00
227cde48d9 write ytmusic stuffs to cache 2026-01-19 14:47:10 -05:00
9ff2252227 allow nodejs to write to ytmusic_cache but for prod too 2026-01-19 12:27:26 -05:00
372620e2c9 allow nodejs to write to ytmusic_cache 2026-01-19 12:27:24 -05:00
4b27236ae3 add cachefile to gitignore 2026-01-19 12:24:58 -05:00
092109b48d Merge pull request 'default to dev branch' (#6) from dev into main
Reviewed-on: #6
2026-01-19 12:13:24 -05:00
f5189af0c9 default to dev branch 2026-01-19 12:13:11 -05:00
e458d8972e Merge pull request 'screw you copilot' (#5) from dev into main
Reviewed-on: #5
2026-01-19 02:42:51 -05:00
b57c92a999 screw you copilot 2026-01-19 02:41:43 -05:00
732d221e11 Merge pull request 'yeet github link from main page; re-add cato's site; update navbar link to say "source" instead of "gitea"' (#4) from dev into main
Reviewed-on: #4
2026-01-19 02:32:04 -05:00
904622cb8b yeet github link from main page; re-add cato's site; update navbar link to say "source" instead of "gitea" 2026-01-19 02:30:50 -05:00
c078dafeac Merge pull request 'Add README & link directly to the repository in navbar' (#3) from dev into main
Reviewed-on: #3
2026-01-19 02:27:38 -05:00
bcf48e078b link directly to the website's source code repo 2026-01-19 02:23:38 -05:00
4f6632ee10 Create README 2026-01-19 02:22:20 -05:00
29d5239721 Merge pull request 'yeet source viewer; replace with gitea' (#2) from dev into main
Reviewed-on: #2
2026-01-19 02:17:40 -05:00
7 changed files with 57 additions and 23 deletions

2
.gitignore vendored
View File

@@ -3,3 +3,5 @@ private/
*/private/
package-lock.json
.env
ytmusic_cache
.vscode

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# oddbyte.dev
This is the source code repository for my website, https://oddbyte.dev.

View File

@@ -29,12 +29,12 @@ const playlistId = 'PLnlTMS4cxfx3-et_L8APzpEgy_eCf18-U';
/**
* Port that nginx proxies to public
*/
const port = process.env.PORT || 48915;
const port = process.env.PORT || 48916;
/**
* Are we prod or dev
*/
const dev = process.env.DEV || false;
const dev = process.env.DEV || "true";
// Helper functions I've made to do things and stuff :P
@@ -88,6 +88,8 @@ async function updateSongs() {
if (typeof playlistSongs == 'object') {
// For each song that youtube moosic has yelled back at us, give them individually to populateThumbnails()
await Promise.all(playlistSongs.map(async song => await populateThumbnails(song)));
// Write all of this to cache
fs.writeFileSync(path.join(baseDir + '/ytmusic_cache'), JSON.stringify({playlistSongs, thumbnails}));
}
else {
// like legit this shouldnt even be possible
@@ -124,6 +126,14 @@ async function send404(req, res) {
// Begin the server-ing things
const app = express();
app.use((req, res, next) => {
if (dev == "true") {
console.log(`got a req to ${req.path}?${req.query} with a body of ${req.body}`);
}
next();
});
var server; // Set at app.listen (bottom), used to kill server on ctrl-c
// YT Music stuff
@@ -261,6 +271,7 @@ async function customConsole() {
const cmd_raw_args = cmd_raw.split(" ");
const cmd_args = cmd_raw_args.slice(1);
const cmd = cmd_raw_args[0];
const cmd_body = cmd_raw.substring(cmd.length).trim();
switch(cmd) {
case "?":
@@ -277,7 +288,7 @@ async function customConsole() {
// ...... i dont know what or how or why but magically it is working now so i am just not gonna touch it and hope
// whatever black magic made it work keeps working .-.
try {
rl.write(eval(cmd_args.toString()) + "\n");
rl.write(eval(cmd_body) + "\n");
} catch (err) {
console.error(err);
}
@@ -296,32 +307,52 @@ async function customConsole() {
}
}
// Wrap in a async function to wait for youtube music response before starting http server
// (to prevent a race condition where people can view the moosic page be4 it is ready)
async function main() {
// Init the moosics stuff (black magic)
await ytmusic.initialize();
// Populate playlistSongs and thumbnails
await updateSongs();
if (dev == "true") console.log("Starting custom console");
// Start console
customConsole(); // DO NOT CALL `await` ON THIS!! THIS WILL CAUSE IT TO NEVER RETURN!!
if (dev == "true") console.log("Console started");
if (dev == "true") console.log("Loading ytmusic stuffs from cache file");
// Load from cache
await (async () => {
let cachefile;
cachefile = fs.readFileSync(path.join(baseDir, '/ytmusic_cache'));
let parsed_cachefile = JSON.parse(cachefile);
playlistSongs = parsed_cachefile.playlistSongs;
thumbnails = parsed_cachefile.thumbnails;
if (dev == "true") console.log("Finished loading from ytmusic stuffs from cache");
})();
// Wrap in async but don't await as to not delay server boot, we can load from cache faster then we can load from yt music
(async () => {
if (dev == "true") console.log("ytmusic init begining");
// Init the moosics stuff
await ytmusic.initialize();
if (dev == "true") console.log("ytmusic initialized");
// Populate playlistSongs and thumbnails
await updateSongs();
if (dev == "true") console.log("Loaded new data from YTMusic!\n");
})();
if (dev == "true") console.log("populating blog index")
// Populate the blog index
await generateBlogIndex();
if (dev == "true") console.log("populated blog index");
server = http.createServer(app);
if (dev == "true") console.log("Starting server");
await (async () => {
server.listen(port, () => {
console.log(`Listening to ${port}`);
console.log(`Listening to ${port}\n`);
// Start hourly loop to update playlist
loopHourly(async () => await updateSongs());
});
})();
// Start console
customConsole();
}
// Handle a few signals

View File

@@ -8,5 +8,5 @@ sudo -iu prod fuser $(sudo -iu prod which node) -k
echo '==== Restarting Nginx ===='
rc-service nginx restart
echo '===== Starting server ===='
screen -dmS portfolio bash -c "sudo -iu prod bash -c 'cd /prod/portfolio && node --permission --allow-fs-read=/prod/portfolio/* .'"
screen -dmS portfolio bash -c "sudo -iu prod bash -c 'cd /prod/portfolio && node --permission --allow-fs-read=/prod/portfolio/* --allow-fs-write=/prod/portfolio/ytmusic_cache .'"
echo 'boosh'

View File

@@ -4,4 +4,4 @@ screen -wipe portfolio_devel
echo '==== Restarting Nginx ===='
rc-service nginx restart
echo '===== Starting server ===='
sudo -iu prod bash -c 'cd /development/website && node --permission --allow-fs-read=/development/website/* .'
sudo -iu prod bash -c 'cd /development/website && node --permission --allow-fs-read=/development/website/* --allow-fs-write=/development/website/ytmusic_cache .'

View File

@@ -33,7 +33,8 @@
Hihi :D<br />
I am a nerd that happens to like hacking stuff.<br />
I mainly nerd about privacy, android, web development, cybersecurity, and sysadmin.<br />
My goal is to become a CISO.
My goal is to become a CISO.<br />
I host my own git server at <a href="/git">/git</a> to gain sysadmin experience and to move off of microslop's github.
</p>
<div id="v-break"></div>
<h2 id="stats" class="selectDisable">Stats</h2>
@@ -80,22 +81,20 @@
<p style="text-align: left; max-width: 500px; align-self:center; display:inline-block;">You can contact me by messaging me on:<br />
- Signal (preferred), <a rel="me" target="_blank" href="https://signal.me/#eu/s6M3E2BSkJVb9E0fwib4PTcbDLH36jPlQTP9basoZ37rl-XoyD5L4Yvao-jZQ0xn">@oddbyte.01</a>,<br />
- Mastodon, <a rel="me" target="_blank" href="https://mastodon.social/@oddbyte">@oddbyte@mastodon.social</a>,<br />
- Github, <a rel="me" target="_blank" href="https://github.com/oddbyte">@oddbyte</a>, or my<br />
- Email, <a rel="me" target="_blank" href="mailto:contact@oddbyte.dev">contact@oddbyte.dev</a><br />
</p>
<div id="v-break"></div>
<h2 id="hoomans" class="selectDisable">Other hooman</h2>
<h2 id="hoomans" class="selectDisable">Other hoomans</h2>
<p>
Check out this random internet person I happen to be aware of: <a target="_blank" href="https://voxel.top">voxel.top</a><br />
He is also a cybersecurity / privacy nerd<br />
His website <s>sucks ass</s> <i>needs improvement</i><br />
<sup>(yeah, lets go with "needs improvement")</sup>
</p>
<%/* <p>
<p>
Check out my buddy's site, <a target="_blank" href="https://catocat.uk">catocat.uk</a><br />
She <i>may</i> have <s>stolen things</s> <i>taken inspiration</i> from my website.
</p>
*/%>
</main>
</div>
</div>

View File

@@ -3,6 +3,6 @@
<a id="button" href="/">Home</a>
<a id="button" href="/art">Art</a>
<a id="button" href="/music">Playlist</a>
<a id="button" href="/git">Gitea</a>
<a id="button" href="/git/oddbyte/website">Source</a>
</div>
</div>