Compare commits
No commits in common. "46f2168fe53b4357cd37cd2d63e8336aeb42a886" and "721497d02effca83c11372f7372e7f65c72bc205" have entirely different histories.
46f2168fe5
...
721497d02e
5 changed files with 10 additions and 98 deletions
57
package-lock.json
generated
57
package-lock.json
generated
|
@ -114,75 +114,18 @@
|
||||||
"fastq": "^1.6.0"
|
"fastq": "^1.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/bson": {
|
|
||||||
"version": "4.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.2.tgz",
|
|
||||||
"integrity": "sha512-+uWmsejEHfmSjyyM/LkrP0orfE2m5Mx9Xel4tXNeqi1ldK5XMQcDsFkBmLDtuyKUbxj2jGDo0H240fbCRJZo7Q==",
|
|
||||||
"requires": {
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/color-name": {
|
"@types/color-name": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
||||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/express": {
|
|
||||||
"version": "github:types/express#7670cf1cbce96b3159e3ff04a253926b34111220",
|
|
||||||
"from": "github:types/express",
|
|
||||||
"requires": {
|
|
||||||
"@types/serve-static": "github:types/npm-serve-static#c1f96843c8b96a37f6c534cb1dadb48f5329e4e0",
|
|
||||||
"path-to-regexp": "github:pillarjs/path-to-regexp#ec285ed3500aed455df59e3b8b07f473412918a4"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"isarray": {
|
|
||||||
"version": "0.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
|
||||||
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
|
|
||||||
},
|
|
||||||
"path-to-regexp": {
|
|
||||||
"version": "github:pillarjs/path-to-regexp#ec285ed3500aed455df59e3b8b07f473412918a4",
|
|
||||||
"from": "github:pillarjs/path-to-regexp#ec285ed3500aed455df59e3b8b07f473412918a4",
|
|
||||||
"requires": {
|
|
||||||
"isarray": "0.0.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/json-schema": {
|
"@types/json-schema": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz",
|
||||||
"integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
|
"integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/mongodb": {
|
|
||||||
"version": "3.5.26",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.5.26.tgz",
|
|
||||||
"integrity": "sha512-p0X2VJgIBNHfNBdZdzzG8eQ/3bf6mQoXDT0UhVyVEdSzXEa1+2pFcwGvEZp72sjztyBwfRKlgrXMjCVavLcuGg==",
|
|
||||||
"requires": {
|
|
||||||
"@types/bson": "*",
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/mongoose": {
|
|
||||||
"version": "5.7.36",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/mongoose/-/mongoose-5.7.36.tgz",
|
|
||||||
"integrity": "sha512-ggFXgvkHgCNlT35B9d/heDYfSqOSwTmQjkRoR32sObGV5Xjd0N0WWuYlLzqeCg94j4hYN/OZxZ1VNNLltX/IVQ==",
|
|
||||||
"requires": {
|
|
||||||
"@types/mongodb": "*",
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/node": {
|
|
||||||
"version": "14.6.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.2.tgz",
|
|
||||||
"integrity": "sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A=="
|
|
||||||
},
|
|
||||||
"@types/serve-static": {
|
|
||||||
"version": "github:types/npm-serve-static#c1f96843c8b96a37f6c534cb1dadb48f5329e4e0",
|
|
||||||
"from": "github:types/npm-serve-static#c1f96843c8b96a37f6c534cb1dadb48f5329e4e0"
|
|
||||||
},
|
|
||||||
"@typescript-eslint/eslint-plugin": {
|
"@typescript-eslint/eslint-plugin": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.1.tgz",
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
"author": "oatmealine",
|
"author": "oatmealine",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/express": "github:types/express",
|
|
||||||
"@types/mongoose": "^5.7.36",
|
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"mongoose": "^5.10.2",
|
"mongoose": "^5.10.2",
|
||||||
"mongoose-int32": "^0.4.1",
|
"mongoose-int32": "^0.4.1",
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>file upload</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<form action="/upload" method="post">
|
|
||||||
<label for="title">Title: </label><br>
|
|
||||||
<input type="text" id="title" name="title"><br>
|
|
||||||
<label for="artist">Artist: </label><br>
|
|
||||||
<input type="text" id="artist" name="artist"><br>
|
|
||||||
<label for="credit">Credit: </label><br>
|
|
||||||
<input type="text" id="credit" name="credit"><br>
|
|
||||||
<input type="submit" value="upload">
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
28
src/index.ts
28
src/index.ts
|
@ -37,48 +37,38 @@ const logger = winston.createLogger({
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
function returnStatic(page) {
|
|
||||||
return (req, res) => {
|
|
||||||
fs.readFile(`src/html/${page}`, 'utf8', (err, data) => {
|
|
||||||
if (err) throw err;
|
|
||||||
res.send(data);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info('connecting to mongodb database');
|
logger.info('connecting to mongodb database');
|
||||||
db.then(() => {
|
db.then(() => {
|
||||||
logger.info('connected to database!');
|
logger.info('connected to database!');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
|
|
||||||
app.set('db', db);
|
app.set('db', db);
|
||||||
app.set('config', config);
|
app.set('config', config);
|
||||||
app.set('logger', logger);
|
app.set('logger', logger);
|
||||||
|
|
||||||
app.get('/upload', returnStatic('upload.html'));
|
app.get('/upload', async (req, res) => { // only for testing, very abusable
|
||||||
|
const file = new File({
|
||||||
app.post('/upload', async (req, res) => { // only for testing, very abusable
|
title: 'penis', // look how mature i am
|
||||||
const file = new File(req.body);
|
artist: 'cock'
|
||||||
|
});
|
||||||
await file.save();
|
await file.save();
|
||||||
|
|
||||||
res.send('uploaded file');
|
res.send('made and saved a sample file');
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/list', async (req, res) => { // only for testing
|
app.get('/list', async (req, res) => { // only for testing
|
||||||
const docs = await File.find({});
|
let docs = await File.find({});
|
||||||
const map = docs.map(d => {
|
docs = docs.map(d => {
|
||||||
const keys = Object.keys(d.toObject()).filter(k => !k.startsWith('_'));
|
const keys = Object.keys(d.toObject()).filter(k => !k.startsWith('_'));
|
||||||
const obj = {};
|
const obj = {};
|
||||||
for (const key of keys) obj[key] = d[key];
|
for (const key of keys) obj[key] = d[key];
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
|
res.send(JSON.stringify(docs));
|
||||||
res.send(JSON.stringify(map));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
|
|
|
@ -16,11 +16,8 @@ const Chart = new Schema({
|
||||||
|
|
||||||
const FileSchema = new Schema({
|
const FileSchema = new Schema({
|
||||||
title: {type: String, default: 'unknown'},
|
title: {type: String, default: 'unknown'},
|
||||||
titleTranslit: String,
|
|
||||||
artist: {type: String, default: 'unknown'},
|
artist: {type: String, default: 'unknown'},
|
||||||
artistTranslit: String,
|
|
||||||
subtitle: String,
|
subtitle: String,
|
||||||
subtitleTranslit: String,
|
|
||||||
credit: String,
|
credit: String,
|
||||||
uploader: {type: String, default: '00000000-0000-4000-a000-000000000000'},
|
uploader: {type: String, default: '00000000-0000-4000-a000-000000000000'},
|
||||||
sample: Sample,
|
sample: Sample,
|
||||||
|
|
Loading…
Reference in a new issue