This commit is contained in:
Flummi 2018-02-18 14:24:48 +01:00
parent fd09bfd1d0
commit 7405165c98
5 changed files with 52 additions and 4 deletions

View File

@ -24,6 +24,7 @@ app
.use("/", router.index) .use("/", router.index)
.use("/v", router.view) .use("/v", router.view)
.use("/a", router.about) .use("/a", router.about)
.use("/test", router.newpaste)
.get("/:uuid", (req, res) => { .get("/:uuid", (req, res) => {
res.send(req.params.uuid); res.send(req.params.uuid);

27
src/lib/index.mjs Normal file
View File

@ -0,0 +1,27 @@
import db from "./sql";
export const getPaste = id => new Promise((resolve, reject) => {
if(id | 0) {
const query = "select p.uuid, p.stamp, p.title, p.paste, l.name as lang, r.uuid as reply from `pastes` as p "
+ "left join `languages` as l on l.id = p.lang "
+ "left join `pastes` as r on r.id = p.reply "
+ "where p.id = ?";
db.exec(query, [id])
.then(row => {
resolve({
uuid: row[0].uuid,
stamp: row[0].stamp,
title: row[0].title,
paste: row[0].paste,
lang: row[0].lang,
reply: row[0].reply
});
})
.catch(err => {
reject(err);
});
}
else {
reject("NaN");
}
});

View File

@ -1,10 +1,12 @@
import index from "./r/index"; import index from "./r/index";
import view from "./r/view"; import view from "./r/view";
import about from "./r/about"; import about from "./r/about";
import newpaste from "./r/new";
export default { export default {
index: index, index: index,
view: view, view: view,
about: about about: about,
newpaste: newpaste
}; };

17
src/routes/r/new.mjs Normal file
View File

@ -0,0 +1,17 @@
import express from "express";
const router = express.Router();
import db from "../../lib/sql";
import * as lib from "../../lib";
router.get("/", (req, res) => {
lib.getPaste(1)
.then(row => {
res.send(row);
})
.catch(err => {
res.send("err");
});
});
export default router;

View File

@ -1,5 +1,6 @@
<h1><a name="about">About fpaste.cc</a></h1> <h1><a name="about">About fpaste.cc</a></h1>
<p>fpaste.cc is here in it&#39;s 1st version and it&#39;s better than expected! A completly written backend in NodeJS makes it possible to develop new features faster than ever before.</p> <p>fpaste.cc is here in it&#39;s 1st version and it&#39;s better than expected! A completly backend written in NodeJS makes it possible to develop new features faster than ever before.</p>
<p>With the <a href="http://www.mariadb.org/">MariaDB</a> database backend fpaste.cc is even more reliable and the <a href="http://expressjs.com">express</a> webserver library offers a powerfull framework.</p> <p>With the <a href="http://www.mariadb.org/">MariaDB</a> database backend fpaste.cc is even more reliable and the <a href="http://expressjs.com">express</a> webserver library offers a powerfull framework.</p>
<p>The <a href="https://github.com/andris9/highlight">highlight highlighting engine</a> offers great support for a variety of programming languages.</p> <p>The <a href="https://github.com/andris9/highlight">highlight.js highlighting engine</a> offers great support for a variety of programming languages.</p>
<p>If you&#39;re interested in the source code of fpaste.cc, take a look at <a href="http://github.com/mcmaniac/npaste.de">github.com</a>. If you have any questions/suggestions or would like to contribute to fpaste.cc feel free to <a href="/a/contact">contact me</a>.</p> <p>If you&#39;re interested in the source code of fpaste.cc, take a look at <a href="http://github.com/mcmaniac/npaste.de">github.com</a>. If you have any questions/suggestions or would like to contribute to fpaste.cc feel free to <a href="/a/contact">contact me</a>.</p>
<p>project stolen from <a href="http://github.com/mcmaniac/npaste.de">github.com/mcmaniac/npaste.de</a></p>