fixes n stuff
i am aware this is the worst commit message ever. leave me alone this is a personal project
This commit is contained in:
parent
bafc0e1e36
commit
1986f71757
12
index.js
12
index.js
|
@ -2,6 +2,7 @@ require('dotenv').config();
|
||||||
|
|
||||||
const postgres = require('postgres');
|
const postgres = require('postgres');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
const bodyParser = require('body-parser');
|
||||||
const app = express();
|
const app = express();
|
||||||
const Hashids = require('hashids');
|
const Hashids = require('hashids');
|
||||||
const expressws = require('express-ws');
|
const expressws = require('express-ws');
|
||||||
|
@ -16,6 +17,8 @@ const storage = multer.diskStorage({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const jsonParser = bodyParser.json();
|
||||||
|
|
||||||
const upload = multer({ storage: storage, fileFilter: (req, file, cb) => {
|
const upload = multer({ storage: storage, fileFilter: (req, file, cb) => {
|
||||||
if (!imageFormats.includes(file.mimetype)) return cb(null, false);
|
if (!imageFormats.includes(file.mimetype)) return cb(null, false);
|
||||||
cb(null, true);
|
cb(null, true);
|
||||||
|
@ -36,9 +39,12 @@ app.use((req, res, next) => {
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/create', async (req, res) => {
|
app.post('/create', jsonParser, async (req, res) => {
|
||||||
const [id] = await sql`SELECT id FROM charts ORDER BY id DESC LIMIT 1`;
|
const [r] = await sql`SELECT id FROM charts ORDER BY id DESC LIMIT 1`;
|
||||||
let newid = (id || 0) + 1;
|
let newid = 1;
|
||||||
|
if (r) newid = r.id + 1;
|
||||||
|
|
||||||
|
console.log(req.body);
|
||||||
|
|
||||||
let body = req.body || {};
|
let body = req.body || {};
|
||||||
await sql`
|
await sql`
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"body-parser": "^1.19.2",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"express": "^4.17.3",
|
"express": "^4.17.3",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"author": "oatmealine",
|
"author": "oatmealine",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"body-parser": "^1.19.2",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"express": "^4.17.3",
|
"express": "^4.17.3",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
|
|
Loading…
Reference in New Issue