diff --git a/.gitignore b/.gitignore
index efe017f..4acb044 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,5 +3,4 @@ node_modules
built
config/config.json
*.log
-.env
-storage/files/*
\ No newline at end of file
+.env
\ No newline at end of file
diff --git a/public/index.html b/public/index.html
index e7190fe..a9d09dd 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,14 +1,14 @@
-
-
-
- Index
-
+
+
+
+ Index
+
-
- Hi
-
+
+ Hi
+
\ No newline at end of file
diff --git a/public/list.html b/public/list.html
index 258bb27..bef0d8b 100644
--- a/public/list.html
+++ b/public/list.html
@@ -1,37 +1,37 @@
-
-
-
- list
-
+
+
+
+ list
+
-
-
-
+
+
+
-
-
+
-
+ let charts = document.createElement('ul');
+ for (const chart of doc.charts) {
+ let l = document.createElement('li');
+ l.innerText = `${chart.difficulty} ${chart.rating} - ${chart.name}\n` +
+ `${chart.steps} steps, ${chart.mines} mines, ${chart.jumps} jumps, ${chart.hands} hands, ${chart.holds} holds, ${chart.rolls} rolls`
+ charts.insertAdjacentElement('beforeend', l);
+ }
+ el.insertAdjacentElement('beforeend', charts);
+ }
+ });
+
+
\ No newline at end of file
diff --git a/public/upload.html b/public/upload.html
index 13b5845..850b5b3 100644
--- a/public/upload.html
+++ b/public/upload.html
@@ -19,7 +19,7 @@
const file = document.getElementById('file');
if (file.files.length) {
console.log(file.files[0]);
-
+
const formData = new FormData();
formData.append('file', file.files[0]);
try {
diff --git a/src/index.ts b/src/index.ts
index b4cf6ee..d58c801 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -54,7 +54,6 @@ db.then(() => {
app.use(express.urlencoded({extended: true}));
app.use(fileUpload({limits: { fileSize: 50 * 1024 * 1024 }}));
app.use(express.static('public', {extensions: ['html', 'htm']}));
- app.use(express.static('storage', {extensions: ['zip']}));
app.use('/assets', express.static('assets'));
app.set('db', db);
diff --git a/src/lib/util.ts b/src/lib/util.ts
new file mode 100644
index 0000000..77a0c60
--- /dev/null
+++ b/src/lib/util.ts
@@ -0,0 +1,10 @@
+import * as fs from 'fs';
+
+export function returnStatic(page) {
+ return (req, res) => {
+ fs.readFile(`src/html/${page}`, 'utf8', (err, data) => {
+ if (err) throw err;
+ res.send(data);
+ });
+ };
+}
\ No newline at end of file
diff --git a/src/upload.ts b/src/upload.ts
index 1a57841..98006c6 100644
--- a/src/upload.ts
+++ b/src/upload.ts
@@ -23,7 +23,7 @@ export function run(app) {
storeEntries: true
});
- zip.on('ready', async () => {
+ zip.on('ready', () => {
const smFile = Object.values(zip.entries()).find((f: any) =>
!f.isDirectory && (f.name.endsWith('.sm'))
);
@@ -36,23 +36,11 @@ export function run(app) {
logger.info(`${chart.artist} - ${chart.title} was just uploaded`);
- let id = 0;
- for (const f of await File.find({})) {
- id = Math.max(f.id, id);
- }
- chart.id = id + 1;
+ const file = new File(chart);
+ file.save();
- chart.createdAt = new Date();
-
- fs.writeFile('./storage/files/' + (id + 1) + '.zip', file.data, (err) => {
- if (err) throw err;
-
- const file = new File(chart);
- file.save();
-
- // TODO: filter out _id and __v? possibly more
- res.send(chart);
- });
+ // TODO: filter out _id and __v? possibly more
+ res.send(chart);
}
zip.close();