boilerplate

This commit is contained in:
Alexandra
2024-10-15 21:03:27 -06:00
parent 2b1cf65731
commit 77a6e121ff
10 changed files with 78 additions and 6 deletions

1
.env Normal file
View File

@@ -0,0 +1 @@
PORT=8062

3
.gitignore vendored
View File

@@ -1 +1,2 @@
node_modules
node_modules
filelist.json

View File

@@ -1,10 +1,10 @@
import fetch from 'node-fetch'
const jsdom = require("jsdom")
import jsdom from "jsdom"
const { JSDOM } = jsdom
global.DOMParser = new JSDOM().window.DOMParser
async function getAllFiles(){
export default async function getAllFiles(){
const url = 'https://myrient.erista.me/files/'
let parents = await getFilesAndFolders(url)
let dirWork = splitFilesAndFolders(parents)
@@ -69,5 +69,3 @@ function splitFilesAndFolders(dirArray){
files: files
}
}
module.exports = {getAllFiles}

13
package-lock.json generated
View File

@@ -5,6 +5,7 @@
"packages": {
"": {
"dependencies": {
"dotenv": "^16.4.5",
"ejs": "^3.1.10",
"express": "^4.21.1",
"fuzzystring": "^1.0.2",
@@ -344,6 +345,18 @@
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dotenv": {
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",

View File

@@ -1,10 +1,12 @@
{
"dependencies": {
"dotenv": "^16.4.5",
"ejs": "^3.1.10",
"express": "^4.21.1",
"fuzzystring": "^1.0.2",
"jsdom": "^25.0.1",
"node-cron": "^3.0.3",
"node-fetch": "^3.3.2"
}
},
"type": "module"
}

12
server.js Normal file
View File

@@ -0,0 +1,12 @@
import getAllFiles from './lib/dirwalk.js'
import 'dotenv/config'
import express from 'express'
var app = express();
app.set('view engine', 'ejs')
app.get('/', function(req, res) {
res.render('pages/index')
})
app.listen(process.env.PORT)
console.log(`Listening on ${process.env.PORT}.`)

24
views/pages/index.ejs Normal file
View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<%- include('../partials/head'); %>
</head>
<body class="container">
<header>
<%- include('../partials/header'); %>
</header>
<main>
<div class="jumbotron">
<h1>This is great</h1>
<p>Welcome to templating using EJS</p>
</div>
</main>
<footer>
<%- include('../partials/footer'); %>
</footer>
</body>
</html>

View File

@@ -0,0 +1,2 @@
<p class="text-center text-muted">&copy; 2024 Alexankitty</p>
<p class="text-center text-muted">Not affiliated with Myrient/Erista!</p>

8
views/partials/head.ejs Normal file
View File

@@ -0,0 +1,8 @@
<meta charset="UTF-8">
<title>EJS Is Fun</title>
<!-- CSS (load bootstrap from a CDN) -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body { padding-top:50px; }
</style>

11
views/partials/header.ejs Normal file
View File

@@ -0,0 +1,11 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="/">EJS Is Fun</a>
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/about">About</a>
</li>
</ul>
</nav>