This commit is contained in:
syuilo 2017-01-17 10:39:21 +09:00
parent bd5c75a152
commit d1b3d53d3b
19 changed files with 28 additions and 29 deletions

View File

@ -47,6 +47,7 @@
"@types/js-yaml": "3.5.29",
"@types/mocha": "2.2.37",
"@types/mongodb": "2.1.36",
"@types/monk": "1.0.5",
"@types/ms": "0.7.29",
"@types/multer": "0.0.32",
"@types/ratelimiter": "2.1.28",
@ -108,7 +109,7 @@
"mime-types": "2.1.14",
"mocha": "3.2.0",
"mongodb": "2.2.21",
"mongoskin": "^2.1.0",
"monk": "3.1.3",
"ms": "0.7.2",
"multer": "1.2.1",
"nprogress": "0.2.0",

View File

@ -1,8 +1,8 @@
import db from '../../db/mongodb';
const collection = db.collection('access_tokens');
const collection = db.get('access_tokens');
collection.createIndex('token');
collection.createIndex('hash');
(collection as any).index('token'); // fuck type definition
(collection as any).index('hash'); // fuck type definition
export default collection;

View File

@ -1,9 +1,9 @@
import db from '../../db/mongodb';
const collection = db.collection('apps');
const collection = db.get('apps');
collection.createIndex('name_id');
collection.createIndex('name_id_lower');
collection.createIndex('secret');
(collection as any).index('name_id'); // fuck type definition
(collection as any).index('name_id_lower'); // fuck type definition
(collection as any).index('secret'); // fuck type definition
export default collection;

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('appdata');
export default db.get('appdata');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('auth_sessions');
export default db.get('auth_sessions');

View File

@ -1,6 +1,6 @@
import db from '../../db/mongodb';
export default db.collection('drive_files');
export default db.get('drive_files');
export function validateFileName(name: string): boolean {
return (

View File

@ -1,6 +1,6 @@
import db from '../../db/mongodb';
export default db.collection('drive_folders');
export default db.get('drive_folders');
export function isValidFolderName(name: string): boolean {
return (

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('drive_tags');
export default db.get('drive_tags');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('favorites');
export default db.get('favorites');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('following');
export default db.get('following');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('likes');
export default db.get('likes');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('messaging_histories');
export default db.get('messaging_histories');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('messaging_messages');
export default db.get('messaging_messages');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('notifications');
export default db.get('notifications');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('posts');
export default db.get('posts');

View File

@ -1,3 +1,3 @@
import db from '../../db/mongodb';
export default db.collection('signin');
export default db.get('signin');

View File

@ -1,9 +1,9 @@
import db from '../../db/mongodb';
const collection = db.collection('users');
const collection = db.get('users');
collection.createIndex('username');
collection.createIndex('token');
(collection as any).index('username'); // fuck type definition
(collection as any).index('token'); // fuck type definition
export default collection;

View File

@ -55,7 +55,7 @@ export default async (req: express.Request, res: express.Response) => {
const secret = '!' + rndstr('a-zA-Z0-9', 32);
// Create account
const inserted = await User.insert({
const account = await User.insert({
token: secret,
avatar_id: null,
banner_id: null,
@ -77,8 +77,6 @@ export default async (req: express.Request, res: express.Response) => {
username_lower: username.toLowerCase()
});
const account = inserted.ops[0];
// Response
res.send(await serialize(account));

View File

@ -1,4 +1,4 @@
const mongo = require('mongoskin');
import * as mongo from 'monk';
import config from '../conf';
@ -6,6 +6,6 @@ const uri = config.mongodb.user && config.mongodb.pass
? `mongodb://${config.mongodb.user}:${config.mongodb.pass}@${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`
: `mongodb://${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`;
const db = mongo.db(uri, { native_parser: true });
const db = mongo(uri);
export default db;