Compare commits
2 Commits
40e686bd7a
...
a1957ff4b7
Author | SHA1 | Date |
---|---|---|
nightly | a1957ff4b7 | |
nightly | 26fdd9e57c |
|
@ -77,7 +77,7 @@
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended"
|
||||||
],
|
],
|
||||||
|
|
||||||
// Enable if you need jsx support
|
// Enable if you need jsx support
|
||||||
|
|
|
@ -12,7 +12,7 @@ const PARTIALS_DIRECTORY = path.join(__dirname, "partials");
|
||||||
const PUBLIC_DIRECTORY = path.join(__dirname, "public");
|
const PUBLIC_DIRECTORY = path.join(__dirname, "public");
|
||||||
const VIEWS_DIRECTORY = path.join(__dirname, "views");
|
const VIEWS_DIRECTORY = path.join(__dirname, "views");
|
||||||
|
|
||||||
export function startWebserver(config:any) {
|
export function startWebserver(config: any) {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.disable("x-powered-by");
|
app.disable("x-powered-by");
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export function startWebserver(config:any) {
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
app.use("/", indexRoutes());
|
app.use("/", indexRoutes());
|
||||||
|
|
||||||
// 404 handler
|
// 404 handler
|
||||||
app.use((req, res) => {
|
app.use((req, res) => {
|
||||||
if (req.accepts("html")) return res.status(404).render("404", { url: req.url, errorCode: 404 });
|
if (req.accepts("html")) return res.status(404).render("404", { url: req.url, errorCode: 404 });
|
||||||
|
@ -49,4 +49,4 @@ export function startWebserver(config:any) {
|
||||||
app.listen(3430, "0.0.0.0", () => {
|
app.listen(3430, "0.0.0.0", () => {
|
||||||
console.log(`Webserver running on port 3430`);
|
console.log(`Webserver running on port 3430`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
{% include "head" %} {% block head %} {% endblock %}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- Main content -->
|
||||||
|
{% block content %} {% endblock %}
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
{% include "footer" %}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
|
||||||
|
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
|
||||||
|
<title>{{ error }}</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
{% block content %} {% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!-- Metadata -->
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
|
||||||
|
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
|
||||||
|
|
||||||
|
<!-- Resources -->
|
||||||
|
<link rel="stylesheet" href="/public/global.css" type="text/css" />
|
||||||
|
|
||||||
|
<!-- Metadata -->
|
||||||
|
/>
|
||||||
|
|
||||||
|
<title>{{ pageTitle }}</title>
|
|
@ -1,14 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>{{title}}</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>{{title}}</h1>
|
|
||||||
|
|
||||||
{% block %}{% endblock %}
|
|
||||||
|
|
||||||
<footer> {% block footer %}{% endblock %} </footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1 +0,0 @@
|
||||||
{{id}} - {{todo}}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
body {
|
||||||
|
background-color: darkcyan;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
body {
|
||||||
|
background-color: darkcyan;
|
||||||
|
}
|
|
@ -8,35 +8,34 @@ import express from "express";
|
||||||
import rateLimit from "express-rate-limit";
|
import rateLimit from "express-rate-limit";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
|
||||||
const indexRateLimit = rateLimit({
|
const indexRateLimit = rateLimit({
|
||||||
windowMs: 1 * 60 * 1000,
|
windowMs: 1 * 60 * 1000,
|
||||||
max: 50,
|
max: 50,
|
||||||
message: "Too many requests in a short period of time.",
|
message: "Too many requests in a short period of time.",
|
||||||
});
|
});
|
||||||
|
|
||||||
export function indexRoutes() {
|
export function indexRoutes() {
|
||||||
// Index
|
// Index
|
||||||
router.get("/", indexRateLimit,async (req,res) => {
|
router.get("/", indexRateLimit, async (req, res) => {
|
||||||
const todos = ['fork and clone', 'make it better', 'make a pull request']
|
const todos = ["fork and clone", "make it better", "make a pull request"];
|
||||||
res.render("index", {
|
res.render("index", {
|
||||||
//locales: getWebLocale(bot, locale),
|
//locales: getWebLocale(bot, locale),
|
||||||
todos: todos,
|
todos: todos,
|
||||||
page: req.url,
|
page: req.url,
|
||||||
//user: user,
|
//user: user,
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
// Gitea
|
|
||||||
router.get("/gitea/", async (_req, res) => {
|
|
||||||
res.redirect(301, "https://tea.nightly.town/Mangoberry/MangoRecipe");
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// robots.txt
|
// Gitea
|
||||||
router.get("/robots.txt", async (_req, res) => {
|
router.get("/gitea/", async (_req, res) => {
|
||||||
res.type("text/plain");
|
res.redirect(301, "https://tea.nightly.town/Mangoberry/MangoRecipe");
|
||||||
res.send("User-agent: *\nCrawl-delay: 5\nDisallow: /public/\nDisallow: /auth/");
|
});
|
||||||
});
|
|
||||||
|
// robots.txt
|
||||||
return router;
|
router.get("/robots.txt", async (_req, res) => {
|
||||||
};
|
res.type("text/plain");
|
||||||
|
res.send("User-agent: *\nCrawl-delay: 5\nDisallow: /public/\nDisallow: /auth/");
|
||||||
|
});
|
||||||
|
|
||||||
|
return router;
|
||||||
|
}
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for todo in todos %}
|
{% for todo in todos %}
|
||||||
<li>{% include 'todo', id:forloop.index %}</li>
|
<li>{% include 'todo', id:forloop.index %}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% block 'footer' %}
|
{% block 'footer' %} Copyright @ 2016, Harttle {% endblock %}
|
||||||
Copyright @ 2016, Harttle
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -3,10 +3,10 @@ import { startWebserver } from "../Webserver/index";
|
||||||
import config from "../../config.json";
|
import config from "../../config.json";
|
||||||
|
|
||||||
export class MangoRecipe {
|
export class MangoRecipe {
|
||||||
config: typeof config;
|
config: typeof config;
|
||||||
// Starts webservers at first boot
|
// Starts webservers at first boot
|
||||||
constructor() {
|
constructor() {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
startWebserver(this);
|
startWebserver(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
import { MangoRecipe } from "./classes/Main";
|
import { MangoRecipe } from "./classes/Main";
|
||||||
import config from "../config.json";
|
import config from "../config.json";
|
||||||
|
|
||||||
new MangoRecipe();
|
new MangoRecipe();
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
|
@ -4,10 +4,19 @@
|
||||||
"description": "A recipe manager with nextjs",
|
"description": "A recipe manager with nextjs",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"build": "tsc",
|
||||||
"build": "next build",
|
"build:purgecss": "cross-env purgecss -c purgecss.config.js -o ./Source/Webserver/public/css/",
|
||||||
"start": "next start",
|
"build:scss": "cross-env sass --no-source-map ./Source/Webserver/public/scss/:./Source/Webserver/public/css/ && npm run build:purgecss",
|
||||||
"lint": "next lint"
|
"build:static": "cross-env copyfiles './Source/Webserver/**/**/*.{css,liquid,jpg,js,png}' './dist/'",
|
||||||
|
"dev": "cross-env concurrently \"cross-env sass ./Source/Webserver/public/scss/:./Source/Webserver/public/css/ --watch\" \"cross-env nodemon\"",
|
||||||
|
"format": "cross-env prettier --config .prettierrc 'Source/**/*.{liquid,js,json,scss,ts}' --write",
|
||||||
|
"lint": "eslint --fix .",
|
||||||
|
"prebuild": "cross-env rimraf ./dist/",
|
||||||
|
"postbuild": "npm run build:scss && npm run build:static",
|
||||||
|
"postinstall": "cross-env copyfiles './node_modules/bulmaselect/dist/index.js' './Source/Webserver/public/js/bulmaselect/' -f",
|
||||||
|
"start": "npm run build && cross-env NODE_ENV=production node dist/Source/index.js",
|
||||||
|
"pm2": "npm run build && pm2 start pm2.config.json",
|
||||||
|
"test": "tsc && eslint ."
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -27,12 +36,16 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
||||||
|
"copyfiles": "^2.4.1",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-rate-limit": "^6.6.0",
|
"express-rate-limit": "^6.6.0",
|
||||||
"express-session": "^1.17.3",
|
"express-session": "^1.17.3",
|
||||||
"liquidjs": "^9.42.0",
|
"liquidjs": "^9.42.0",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
|
"purgecss": "^5.0.0",
|
||||||
|
"sass": "^1.55.0",
|
||||||
"terser": "^5.15.1"
|
"terser": "^5.15.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
module.exports = {
|
||||||
|
content: ["./Source/Webserver/**/**/*.{liquid,js}"],
|
||||||
|
css: ["./Source/Webserver/**/**/*.css"],
|
||||||
|
fontFace: true,
|
||||||
|
variables: true,
|
||||||
|
keyframes: true,
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue