summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-01-17 10:39:21 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-01-17 10:39:21 +0900
commit19e12bf5cf6f56aed429333594444a40184c8a06 (patch)
tree5d1a5533b21743dea82a9db9b2bb8fdb99530321 /src/api
parent[Test] Fix bug (diff)
downloadsharkey-19e12bf5cf6f56aed429333594444a40184c8a06.tar.gz
sharkey-19e12bf5cf6f56aed429333594444a40184c8a06.tar.bz2
sharkey-19e12bf5cf6f56aed429333594444a40184c8a06.zip
:v:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/models/access-token.ts6
-rw-r--r--src/api/models/app.ts8
-rw-r--r--src/api/models/appdata.ts2
-rw-r--r--src/api/models/auth-session.ts2
-rw-r--r--src/api/models/drive-file.ts2
-rw-r--r--src/api/models/drive-folder.ts2
-rw-r--r--src/api/models/drive-tag.ts2
-rw-r--r--src/api/models/favorite.ts2
-rw-r--r--src/api/models/following.ts2
-rw-r--r--src/api/models/like.ts2
-rw-r--r--src/api/models/messaging-history.ts2
-rw-r--r--src/api/models/messaging-message.ts2
-rw-r--r--src/api/models/notification.ts2
-rw-r--r--src/api/models/post.ts2
-rw-r--r--src/api/models/signin.ts2
-rw-r--r--src/api/models/user.ts6
-rw-r--r--src/api/private/signup.ts4
17 files changed, 24 insertions, 26 deletions
diff --git a/src/api/models/access-token.ts b/src/api/models/access-token.ts
index a242865473..ff7189fa3b 100644
--- a/src/api/models/access-token.ts
+++ b/src/api/models/access-token.ts
@@ -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;
diff --git a/src/api/models/app.ts b/src/api/models/app.ts
index 39bb6cfa60..68d74be324 100644
--- a/src/api/models/app.ts
+++ b/src/api/models/app.ts
@@ -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;
diff --git a/src/api/models/appdata.ts b/src/api/models/appdata.ts
index 8dab199fef..5224ccfc3b 100644
--- a/src/api/models/appdata.ts
+++ b/src/api/models/appdata.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('appdata');
+export default db.get('appdata');
diff --git a/src/api/models/auth-session.ts b/src/api/models/auth-session.ts
index 1ee8299f54..308b4adce8 100644
--- a/src/api/models/auth-session.ts
+++ b/src/api/models/auth-session.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('auth_sessions');
+export default db.get('auth_sessions');
diff --git a/src/api/models/drive-file.ts b/src/api/models/drive-file.ts
index cc49cf44c8..64e023534f 100644
--- a/src/api/models/drive-file.ts
+++ b/src/api/models/drive-file.ts
@@ -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 (
diff --git a/src/api/models/drive-folder.ts b/src/api/models/drive-folder.ts
index 44e6c6f5c5..aa9e0712dc 100644
--- a/src/api/models/drive-folder.ts
+++ b/src/api/models/drive-folder.ts
@@ -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 (
diff --git a/src/api/models/drive-tag.ts b/src/api/models/drive-tag.ts
index e4b044242b..3e2e93b394 100644
--- a/src/api/models/drive-tag.ts
+++ b/src/api/models/drive-tag.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('drive_tags');
+export default db.get('drive_tags');
diff --git a/src/api/models/favorite.ts b/src/api/models/favorite.ts
index 448b007777..0aef3deed6 100644
--- a/src/api/models/favorite.ts
+++ b/src/api/models/favorite.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('favorites');
+export default db.get('favorites');
diff --git a/src/api/models/following.ts b/src/api/models/following.ts
index d509c60d8c..9dd2ba1400 100644
--- a/src/api/models/following.ts
+++ b/src/api/models/following.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('following');
+export default db.get('following');
diff --git a/src/api/models/like.ts b/src/api/models/like.ts
index 7c571b91cb..301ef7c75f 100644
--- a/src/api/models/like.ts
+++ b/src/api/models/like.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('likes');
+export default db.get('likes');
diff --git a/src/api/models/messaging-history.ts b/src/api/models/messaging-history.ts
index a06a7dd386..9d96d996db 100644
--- a/src/api/models/messaging-history.ts
+++ b/src/api/models/messaging-history.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('messaging_histories');
+export default db.get('messaging_histories');
diff --git a/src/api/models/messaging-message.ts b/src/api/models/messaging-message.ts
index 1e6865d45f..498186e4c8 100644
--- a/src/api/models/messaging-message.ts
+++ b/src/api/models/messaging-message.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('messaging_messages');
+export default db.get('messaging_messages');
diff --git a/src/api/models/notification.ts b/src/api/models/notification.ts
index b53db4f0b4..6ec7c53eef 100644
--- a/src/api/models/notification.ts
+++ b/src/api/models/notification.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('notifications');
+export default db.get('notifications');
diff --git a/src/api/models/post.ts b/src/api/models/post.ts
index 04468dd2ae..97dc9d648f 100644
--- a/src/api/models/post.ts
+++ b/src/api/models/post.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('posts');
+export default db.get('posts');
diff --git a/src/api/models/signin.ts b/src/api/models/signin.ts
index 151a0359e9..11e6bf06b8 100644
--- a/src/api/models/signin.ts
+++ b/src/api/models/signin.ts
@@ -1,3 +1,3 @@
import db from '../../db/mongodb';
-export default db.collection('signin');
+export default db.get('signin');
diff --git a/src/api/models/user.ts b/src/api/models/user.ts
index 5645d38568..25b7999ba0 100644
--- a/src/api/models/user.ts
+++ b/src/api/models/user.ts
@@ -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;
diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts
index 34e98db284..1eb6abfe9f 100644
--- a/src/api/private/signup.ts
+++ b/src/api/private/signup.ts
@@ -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));