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

View file

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

View file

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

View file

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

View file

@ -1,3 +1,3 @@
import db from '../../db/mongodb'; 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'; 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'; import db from '../../db/mongodb';
export default db.collection('drive_files'); export default db.get('drive_files');
export function validateFileName(name: string): boolean { export function validateFileName(name: string): boolean {
return ( return (

View file

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

View file

@ -1,3 +1,3 @@
import db from '../../db/mongodb'; 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'; 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'; 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'; 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'; 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'; 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'; 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'; 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'; 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'; import db from '../../db/mongodb';
const collection = db.collection('users'); const collection = db.get('users');
collection.createIndex('username'); (collection as any).index('username'); // fuck type definition
collection.createIndex('token'); (collection as any).index('token'); // fuck type definition
export default collection; 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); const secret = '!' + rndstr('a-zA-Z0-9', 32);
// Create account // Create account
const inserted = await User.insert({ const account = await User.insert({
token: secret, token: secret,
avatar_id: null, avatar_id: null,
banner_id: null, banner_id: null,
@ -77,8 +77,6 @@ export default async (req: express.Request, res: express.Response) => {
username_lower: username.toLowerCase() username_lower: username.toLowerCase()
}); });
const account = inserted.ops[0];
// Response // Response
res.send(await serialize(account)); res.send(await serialize(account));

View file

@ -1,4 +1,4 @@
const mongo = require('mongoskin'); import * as mongo from 'monk';
import config from '../conf'; 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.user}:${config.mongodb.pass}@${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`
: `mongodb://${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; export default db;