|
|
|
@ -2,6 +2,7 @@ require('dotenv').config();
|
|
|
|
|
|
|
|
|
|
const postgres = require('postgres');
|
|
|
|
|
const express = require('express');
|
|
|
|
|
const bodyParser = require('body-parser');
|
|
|
|
|
const app = express();
|
|
|
|
|
const Hashids = require('hashids');
|
|
|
|
|
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) => {
|
|
|
|
|
if (!imageFormats.includes(file.mimetype)) return cb(null, false);
|
|
|
|
|
cb(null, true);
|
|
|
|
@ -36,9 +39,12 @@ app.use((req, res, next) => {
|
|
|
|
|
next();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.post('/create', async (req, res) => {
|
|
|
|
|
const [id] = await sql`SELECT id FROM charts ORDER BY id DESC LIMIT 1`;
|
|
|
|
|
let newid = (id || 0) + 1;
|
|
|
|
|
app.post('/create', jsonParser, async (req, res) => {
|
|
|
|
|
const [r] = await sql`SELECT id FROM charts ORDER BY id DESC LIMIT 1`;
|
|
|
|
|
let newid = 1;
|
|
|
|
|
if (r) newid = r.id + 1;
|
|
|
|
|
|
|
|
|
|
console.log(req.body);
|
|
|
|
|
|
|
|
|
|
let body = req.body || {};
|
|
|
|
|
await sql`
|
|
|
|
|