diff --git a/.gitignore b/.gitignore
index 16f05df..e8f682b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -88,7 +88,3 @@ sw.*
# Vim swap files
*.swp
-
-# db file
-db.json
-pass
\ No newline at end of file
diff --git a/api/index.js b/api/index.js
index 6bb29be..c9af6bf 100644
--- a/api/index.js
+++ b/api/index.js
@@ -1,22 +1,36 @@
-const express = require("express");
+const express = require("express")
const {gimmeToken} = require("./util.js")
-const { MongoClient } = require("mongodb");
+const { MongoClient } = require("mongodb")
require("dotenv").config()
-const app = express();
-app.use(express.json());
-app.use(express.urlencoded({ extended: false }));
-
-const client = new MongoClient(process.env.DATABASE);
-const PASS = process.env.PASS
-let TOKEN = gimmeToken();
-
+// routes
/*
* error: 0 -> no error
* error: 1 -> parameter error
* error: 2 -> auth error
* error: 3 -> not found error
*/
+const resources = require("./routes/resources.js")
+const projects = require("./routes/projects.js")
+const blog = require("./routes/blog.js")
+const auth = require("./routes/auth.js")
+
+const app = express()
+app.use(express.json())
+app.use(express.urlencoded({ extended: false }));
+app.use("/resources", resources)
+app.use("/projects", projects)
+app.use("/blog", blog)
+app.use("/auth", auth)
+
+const db = new MongoClient(process.env.DATABASE);
+const PASS = process.env.PASS
+let TOKEN = gimmeToken();
+
+app.use((req, res, next) => {
+ req.db = db;
+ next();
+})
// PATH: /api/login
// METHOD: GET
@@ -26,7 +40,7 @@ app.get("/login", (req,res)=>{
if (pass === undefined)
return res.json({error: 1})
-
+
if (pass !== PASS)
return res.json({error: 2})
@@ -41,7 +55,7 @@ app.get("/logout", (req,res)=>{
if (token === undefined)
return res.json({error: 1})
-
+
if (token !== TOKEN)
return res.json({error: 2})
@@ -65,10 +79,10 @@ app.get("/add_project", async (req, res) => {
url === undefined
)
return res.json({error: 1})
-
+
if (token !== TOKEN)
return res.json({error: 2})
-
+
await client.connect()
const db = await client.db("ngn13")
const col = await db.collection("projects")
@@ -93,10 +107,10 @@ app.get("/add_resource", async (req, res) => {
url === undefined
)
return res.json({error: 1})
-
+
if (token !== TOKEN)
return res.json({error: 2})
-
+
await client.connect()
const db = await client.db("ngn13")
const col = await db.collection("resources")
@@ -129,6 +143,18 @@ app.get("/get_resources", async (req, res) => {
res.json({error: 0, resources:array})
});
+// PATH: /api/get_resources
+// METHOD: GET
+// PARAMETERS: NONE
+app.get("/get_resources", async (req, res) => {
+ await client.connect()
+ const db = await client.db("ngn13")
+ const col = await db.collection("resources")
+ const array = await col.find().toArray()
+ await client.close()
+ res.json({error: 0, resources:array})
+});
+
// PATH: /api/add_post
// METHOD: POST
// PARAMETERS: token, title, author, content
@@ -145,16 +171,16 @@ app.post("/add_post", async (req, res) => {
content === undefined
)
return res.json({error: 1})
-
+
if (token !== TOKEN)
return res.json({error: 2})
-
+
await client.connect()
const db = await client.db("ngn13")
const col = await db.collection("posts")
await col.insertOne({
- "title":title,
- "author":author,
+ "title":title,
+ "author":author,
"date": new Date().toLocaleDateString(),
"content":content
})
diff --git a/api/routes/resources.js b/api/routes/resources.js
new file mode 100644
index 0000000..2cfd1cc
--- /dev/null
+++ b/api/routes/resources.js
@@ -0,0 +1,12 @@
+const express = require("express")
+const resources = express.Router()
+
+resources.get("/get", async (req,res)=>{
+ await req.db.connect()
+ const col = await req.db.collection("ngn13")
+ const results = col.find().limit(10).toArray()
+ await req.db.close()
+ res.json({ error: 0, resources: results })
+})
+
+module.exports = resources
diff --git a/components/Project.vue b/components/Project.vue
index 049aba1..6eb9133 100644
--- a/components/Project.vue
+++ b/components/Project.vue
@@ -30,8 +30,8 @@ main {
padding: 40px;
cursor: pointer;
transition: .4s;
- height: 13%;
- width: 27%;
+ height: 100px;
+ width: 80%;
}
main:hover{
@@ -56,7 +56,7 @@ h2{
@media only screen and (max-width: 1121px) {
main{
- width: auto;
+ width: 80%;
}
}
-
\ No newline at end of file
+
diff --git a/components/ProjectList.vue b/components/ProjectList.vue
index 794a42e..0b320c1 100644
--- a/components/ProjectList.vue
+++ b/components/ProjectList.vue
@@ -15,6 +15,7 @@ div{
display: flex;
flex-direction: row;
padding: 15px;
+ align-items: center;
justify-content: center;
gap: 30px;
}
@@ -24,4 +25,4 @@ div{
flex-direction: column;
}
}
-
\ No newline at end of file
+
diff --git a/nuxt.zip b/nuxt.zip
new file mode 100644
index 0000000..aa89281
Binary files /dev/null and b/nuxt.zip differ
diff --git a/package.json b/package.json
index 54d2b1c..c72dc70 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "my-website",
- "version": "2.2.0",
+ "version": "2.3.0",
"private": true,
"scripts": {
"dev": "nuxt",
diff --git a/pages/index.vue b/pages/index.vue
index a13c8bd..23f12be 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -24,20 +24,22 @@
👉 Contact me
You can contact me on the following platforms:
-
+
Discord
Github
+ Mastodon
+
Mail
- or private message me on
+ or private message me on matrix:
[matrix] @ngn:matrix.ngn13.fun
v2.2
+v2.3