diff --git a/.gitignore b/.gitignore index 04c5395e..b33f5ae2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. +the_big_db.db + # dependencies node_modules /.pnp diff --git a/client/src/landing/GraphRender.jsx b/client/src/landing/GraphRender.jsx index 106edee6..ffafbf72 100644 --- a/client/src/landing/GraphRender.jsx +++ b/client/src/landing/GraphRender.jsx @@ -1,3 +1,4 @@ +import { useEffect } from 'react'; import { SigmaContainer } from "@react-sigma/core"; import "@react-sigma/core/lib/react-sigma.min.css"; @@ -13,17 +14,23 @@ export default function GraphRender() { queryFn: fetchGraph }); - let outputStuff; - if (isPending) outputStuff = "Loading..."; - else if (error) outputStuff = `Error encountered: ${error}`; - else outputStuff = ( + useEffect(() => { + if (data) { + const supervisor = new ForceSupervisor(data, {allowInvalidContainer: true}); + + supervisor.start(); + + return () => supervisor.stop(); + } + }); + + if (isPending) return "Loading..."; + else if (error) return `Error encountered: ${error}`; + else return ( ); - - if (data) (new ForceSupervisor(data, {allowInvalidContainer: true})).start(); - return outputStuff; } \ No newline at end of file diff --git a/client/src/login/LogIn.jsx b/client/src/login/LogIn.jsx new file mode 100644 index 00000000..948c7e34 --- /dev/null +++ b/client/src/login/LogIn.jsx @@ -0,0 +1 @@ +LogIn.jsx \ No newline at end of file diff --git a/db/initialize_db.js b/db/initialize_db.js index e08351be..c10364db 100644 --- a/db/initialize_db.js +++ b/db/initialize_db.js @@ -1,7 +1,6 @@ const libsql = require("@libsql/client"); const showdown = require("showdown"); - const createPages = ` create table if not exists pages ( id integer primary key, diff --git a/db/populate_db.js b/db/populate_db.js deleted file mode 100644 index 361860fe..00000000 --- a/db/populate_db.js +++ /dev/null @@ -1,19 +0,0 @@ -const libsql = require("@libsql/client") - -const insert = ` -insert into pages (title, description) values ( - 'main', - 'this is the main page.\n\nit describes a large field in which you stand.' -) -` - -async function initDb() { - const config = { - url: "http://127.0.0.1:8000" - }; - const db = libsql.createClient(config); - - const cIns = await db.execute(insert); - console.log(cIns); -} -initDb() \ No newline at end of file diff --git a/db/the_big_db.db/dbs/default/.sentinel b/db/the_big_db.db/dbs/default/.sentinel deleted file mode 100644 index e69de29b..00000000 diff --git a/db/the_big_db.db/dbs/default/stats.json b/db/the_big_db.db/dbs/default/stats.json index ad2d8103..92cbb687 100644 --- a/db/the_big_db.db/dbs/default/stats.json +++ b/db/the_big_db.db/dbs/default/stats.json @@ -1 +1 @@ -{"id":"7de13931-444c-4dd2-a19a-5cd1e70b7f36","rows_written":149,"rows_read":14035,"storage_bytes_used":20480,"write_requests_delegated":0,"current_frame_no":151,"top_query_threshold":0,"top_queries":[{"rows_written":0,"rows_read":16,"query":"select id, html from pages"},{"rows_written":0,"rows_read":16,"query":"select id, title from pages"},{"rows_written":0,"rows_read":17,"query":"select id, html from pages"},{"rows_written":0,"rows_read":17,"query":"select id, title from pages"},{"rows_written":0,"rows_read":18,"query":"select id, html from pages"},{"rows_written":0,"rows_read":18,"query":"select id, title from pages"},{"rows_written":0,"rows_read":19,"query":"select id, html from pages"},{"rows_written":0,"rows_read":19,"query":"select id, title from pages"},{"rows_written":0,"rows_read":19,"query":"select id, html from pages"},{"rows_written":0,"rows_read":19,"query":"select id, title from pages"}],"slowest_query_threshold":0,"slowest_queries":[{"elapsed_ms":0,"query":"select title from pages","rows_written":0,"rows_read":1},{"elapsed_ms":0,"query":"select title from pages","rows_written":0,"rows_read":2},{"elapsed_ms":1,"query":"\nalter table pages \nadd column html text\n","rows_written":1,"rows_read":4},{"elapsed_ms":1,"query":"\ncreate table if not exists renders (\n id integer primary key,\n title varchar(255),\n description text\n)\n","rows_written":2,"rows_read":1},{"elapsed_ms":1,"query":"insert into pages (title, description) values (?, ?) returning id","rows_written":1,"rows_read":1},{"elapsed_ms":1,"query":"replace into pages (id, title, description) values (?, ?, ?)","rows_written":1,"rows_read":1},{"elapsed_ms":1,"query":"replace into pages (id, title, description, html) values (?, ?, ?, ?)","rows_written":1,"rows_read":1},{"elapsed_ms":1,"query":"select * from pages where id=@val","rows_written":0,"rows_read":1},{"elapsed_ms":1,"query":"select count(*) as num_pages from pages","rows_written":0,"rows_read":1},{"elapsed_ms":7,"query":"replace into pages (id, title, description) values (?, ?, ?)","rows_written":1,"rows_read":1}],"embedded_replica_frames_replicated":0,"query_count":1996,"query_latency":165200} \ No newline at end of file +{"id":"7de13931-444c-4dd2-a19a-5cd1e70b7f36","rows_written":149,"rows_read":15691,"storage_bytes_used":20480,"write_requests_delegated":0,"current_frame_no":151,"top_query_threshold":0,"top_queries":[{"rows_written":0,"rows_read":16,"query":"select id, title from pages"},{"rows_written":0,"rows_read":17,"query":"select id, html from pages"},{"rows_written":0,"rows_read":17,"query":"select id, title from pages"},{"rows_written":0,"rows_read":18,"query":"select id, html from pages"},{"rows_written":0,"rows_read":18,"query":"select id, title from pages"},{"rows_written":0,"rows_read":19,"query":"select id, html from pages"},{"rows_written":0,"rows_read":19,"query":"select id, title from pages"},{"rows_written":0,"rows_read":1,"query":"select * from pages where id=?"},{"rows_written":0,"rows_read":19,"query":"select id, html from pages"},{"rows_written":0,"rows_read":19,"query":"select id, title from pages"}],"slowest_query_threshold":0,"slowest_queries":[{"elapsed_ms":0,"query":"select title from pages","rows_written":0,"rows_read":1},{"elapsed_ms":0,"query":"select title from pages","rows_written":0,"rows_read":2},{"elapsed_ms":1,"query":"\nalter table pages \nadd column html text\n","rows_written":1,"rows_read":4},{"elapsed_ms":1,"query":"\ncreate table if not exists renders (\n id integer primary key,\n title varchar(255),\n description text\n)\n","rows_written":2,"rows_read":1},{"elapsed_ms":1,"query":"insert into pages (title, description) values (?, ?) returning id","rows_written":1,"rows_read":1},{"elapsed_ms":1,"query":"replace into pages (id, title, description) values (?, ?, ?)","rows_written":1,"rows_read":1},{"elapsed_ms":1,"query":"replace into pages (id, title, description, html) values (?, ?, ?, ?)","rows_written":1,"rows_read":1},{"elapsed_ms":1,"query":"select * from pages where id=@val","rows_written":0,"rows_read":1},{"elapsed_ms":1,"query":"select count(*) as num_pages from pages","rows_written":0,"rows_read":1},{"elapsed_ms":7,"query":"replace into pages (id, title, description) values (?, ?, ?)","rows_written":1,"rows_read":1}],"embedded_replica_frames_replicated":0,"query_count":2086,"query_latency":171851} \ No newline at end of file diff --git a/server/api.js b/server/api.js index 5cef24e7..0aa3bcb7 100644 --- a/server/api.js +++ b/server/api.js @@ -53,4 +53,20 @@ app.get('/graph', (req, res) => { .catch((error) => res.status(500).json({"error": error})); }); +// auth stuff +app.post('/register', (req, res) => { + // parse the body, which miight be url-encoded? + // check if the nonce password is correctt + // hash the password + // add tthe user to the users database +}); + +app.post('/login', (req, res) => { + // hash the password + // check if the user/hashed pass matches + // if not, throw an error + // create a valid ttoken? + // return token +}); + module.exports = app; \ No newline at end of file diff --git a/server/server.js b/server/server.js index 83dad1b3..14e3d88b 100644 --- a/server/server.js +++ b/server/server.js @@ -5,12 +5,6 @@ const port = process.env.PORT || 3001; // Use the port provided by the host or d const app = express(); app.use(express.json()); -app.use(function (req, res, next) { - res.setHeader("Access-Control-Allow-Origin", "*"); - res.setHeader('Access-Control-Allow-Methods', '*'); - res.setHeader("Access-Control-Allow-Headers", "*"); - next(); -}); app.use("/api", apiRoutes);