how did i live without types

This commit is contained in:
oat 2020-09-02 17:44:44 +03:00
parent 7121c06d7b
commit 46f2168fe5
Signed by: oat
GPG key ID: DD83A9617A252385
3 changed files with 65 additions and 4 deletions

57
package-lock.json generated
View file

@ -114,18 +114,75 @@
"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": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
"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": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz",
"integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
"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": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.1.tgz",

View file

@ -11,6 +11,8 @@
"author": "oatmealine",
"license": "MIT",
"dependencies": {
"@types/express": "github:types/express",
"@types/mongoose": "^5.7.36",
"express": "^4.17.1",
"mongoose": "^5.10.2",
"mongoose-int32": "^0.4.1",

View file

@ -52,7 +52,8 @@ db.then(() => {
const app = express();
app.use(express.urlencoded({ extended: true }));
// @ts-ignore
app.use(express.urlencoded({extended: true}));
app.set('db', db);
app.set('config', config);
@ -68,15 +69,16 @@ db.then(() => {
});
app.get('/list', async (req, res) => { // only for testing
let docs = await File.find({});
docs = docs.map(d => {
const docs = await File.find({});
const map = docs.map(d => {
const keys = Object.keys(d.toObject()).filter(k => !k.startsWith('_'));
const obj = {};
for (const key of keys) obj[key] = d[key];
return obj;
});
res.send(JSON.stringify(docs));
res.send(JSON.stringify(map));
});
app.get('/', (req, res) => {