瀏覽代碼

Moved model to shared module

master
kj1352 4 年之前
父節點
當前提交
25b24cda13
共有 16 個檔案被更改,包括 30 行新增3282 行删除
  1. +3
    -0
      .gitmodules
  2. +11
    -3179
      package-lock.json
  3. +1
    -1
      src/library/library-routes.ts
  4. +1
    -1
      src/management-scripts/compile-library.ts
  5. +0
    -12
      src/models/category.ts
  6. +0
    -8
      src/models/recollection-history.ts
  7. +0
    -26
      src/models/shelf.ts
  8. +0
    -18
      src/models/user.ts
  9. +0
    -3
      src/models/variables.ts
  10. +0
    -21
      src/models/word.ts
  11. +4
    -4
      src/revision/revision-routes.ts
  12. +1
    -0
      src/shared
  13. +2
    -2
      src/user-profile/category-routes.ts
  14. +2
    -2
      src/user-profile/profile-routes.ts
  15. +2
    -2
      src/user-profile/recollection-history-routes.ts
  16. +3
    -3
      src/user-profile/shelf-routes.ts

+ 3
- 0
.gitmodules 查看文件

@@ -0,0 +1,3 @@
[submodule "src/shared"]
path = src/shared
url = git@code.webtrigon.com:kj/anamnesis-shared.git

+ 11
- 3179
package-lock.json
文件差異過大導致無法顯示
查看文件


+ 1
- 1
src/library/library-routes.ts 查看文件

@@ -1,7 +1,7 @@
import express from 'express';
import passport from 'passport';
import { DB_NAME, getDatabaseClient } from '../db-utils';
import { Word } from '../models/word';
import { Word } from '../shared/models/word';

export const libraryRoutes = express.Router();



+ 1
- 1
src/management-scripts/compile-library.ts 查看文件

@@ -1,4 +1,4 @@
import { gramaticalDetail, Word } from "../models/word";
import { gramaticalDetail, Word } from "../shared/models/word";
import { getDatabaseClient, DB_NAME, connectToDatabaseServer } from "../db-utils";
import da from '../default-library/DA.json';
import db from '../default-library/DB.json';


+ 0
- 12
src/models/category.ts 查看文件

@@ -1,12 +0,0 @@
import { Shelf } from "./shelf";

export interface Category { //_id is not needed as it is created by default
name: string,
icon: string,
shelves?: Array<Shelf>,
isArchived: boolean,
}

export interface MongoCategory extends Omit<Category, 'shelves'> {
shelves?: Array<string>, // Shelf IDs
}

+ 0
- 8
src/models/recollection-history.ts 查看文件

@@ -1,8 +0,0 @@
export interface RecollectionHistory {
userId: string,
wordId: string,
history: Array<{
timeStamp: Date,
wasRecallSuccessful: boolean
}>
}

+ 0
- 26
src/models/shelf.ts 查看文件

@@ -1,26 +0,0 @@
import { viewPermissionType } from "./variables";
import { Word } from "./word";

interface ShelfWord {
word: Word,
notes: Array<string>,
nextRevisionDateTime: Date,
spaceBetweenRecall: number, // in Days
isArchived: boolean,
}

export interface Shelf {
name: string,
description?: string,
viewType: viewPermissionType,
isArchived: boolean,
words?: Array<ShelfWord>
}

export interface MongoShelfWord extends Omit<ShelfWord, "word"> {
word: string,
}

export interface MongoShelf extends Omit<Shelf, "words"> {
words?: Array<MongoShelfWord>
}

+ 0
- 18
src/models/user.ts 查看文件

@@ -1,18 +0,0 @@
import { Category } from "./category";
import { Word } from "./word";

export interface User {
_id: string,
name: string,
email: string,
password: string,
isVerified: boolean,
otp: number,
categories?: Array<Category>,
favouriteWords?: Array<Word>,
}

export interface MongoUser extends Omit<User, "categories" | "favouriteWords"> {
categories?: Array<string> // Category IDs,
favouriteWords?: Array<string> // Favourite Words ID
}

+ 0
- 3
src/models/variables.ts 查看文件

@@ -1,3 +0,0 @@
export type grammarType = 'NOUN' | 'PRONOUN' | 'ADJECTIVE' | 'VERB' | 'ADVERB' | 'PREPOSITION' | 'CONJUNCTION' | 'INTERJECTION';
export type viewPermissionType = 'PUBLIC' | 'PRIVATE' | 'FRIENDS' | 'FOLLOWERS';
export type LanguageType = 'ENGLISH' | 'KANNADA' | 'HINDI' | 'TAMIL' | 'TELUGU';

+ 0
- 21
src/models/word.ts 查看文件

@@ -1,21 +0,0 @@
import { grammarType, LanguageType } from "./variables";

export interface gramaticalDetail {
type: grammarType,
description: string,
context: Array<string>,
examples: Array<string>,
}

export interface Word {
//_id is present by default in the DB
name: string,
languageType: LanguageType,
pronounciation?: {
text: string,
audio?: string,
},
similarWords?: Array<string>,
oppositeWords?: Array<string>,
grammaticalDetails: Array<gramaticalDetail>,
}

+ 4
- 4
src/revision/revision-routes.ts 查看文件

@@ -1,11 +1,11 @@
import express from 'express';
import passport from 'passport';
import { MongoShelf, MongoShelfWord } from '../models/shelf';
import { MongoShelf, MongoShelfWord } from '../shared/models/shelf';
import { DB_NAME, getDatabaseClient } from '../db-utils';
import { MongoCategory } from '../models/category';
import { MongoUser } from '../models/user';
import { MongoCategory } from '../shared/models/category';
import { MongoUser } from '../shared/models/user';
import { ObjectId } from 'bson';
import { RecollectionHistory } from '../models/recollection-history';
import { RecollectionHistory } from '../shared/models/recollection-history';

export const recollectionRoutes = express.Router();



+ 1
- 0
src/shared

@@ -0,0 +1 @@
Subproject commit 7dc8d39f1be0f5159aa473de31620a72c77b98af

+ 2
- 2
src/user-profile/category-routes.ts 查看文件

@@ -1,10 +1,10 @@
import express from 'express';
import passport from 'passport';
import { MongoUser } from '../models/user';
import { MongoUser } from '../shared/models/user';
import { DB_NAME } from '../db-utils';
import { getDatabaseClient } from '../db-utils';
import { ObjectId } from 'bson';
import { MongoCategory } from '..//models/category';
import { MongoCategory } from '..//shared/models/category';

export const categoryRoutes = express.Router();



+ 2
- 2
src/user-profile/profile-routes.ts 查看文件

@@ -1,9 +1,9 @@
import express from 'express';
import passport from 'passport';
import { DB_NAME, getDatabaseClient } from '../db-utils';
import { MongoUser } from '../models/user';
import { MongoUser } from '../shared/models/user';
import { ObjectId } from 'bson';
import { Word } from '../models/word';
import { Word } from '../shared/models/word';

export const userProfileRoutes = express.Router();



+ 2
- 2
src/user-profile/recollection-history-routes.ts 查看文件

@@ -1,8 +1,8 @@
import { RecollectionHistory } from '../models/recollection-history';
import { RecollectionHistory } from '../shared/models/recollection-history';
import express from 'express';
import passport from 'passport';
import { DB_NAME, getDatabaseClient } from '../db-utils';
import { MongoUser } from '../models/user';
import { MongoUser } from '../shared/models/user';

export const recollectionHistoryRoutes = express.Router();



+ 3
- 3
src/user-profile/shelf-routes.ts 查看文件

@@ -1,11 +1,11 @@
import { ObjectId } from 'bson';
import express from 'express';
import passport from 'passport';
import { MongoCategory } from '../models/category';
import { MongoCategory } from '../shared/models/category';
import { DB_NAME } from '../db-utils';
import { getDatabaseClient } from '../db-utils';
import { MongoShelfWord, MongoShelf } from '../models/shelf';
import { Word } from '../models/word';
import { MongoShelfWord, MongoShelf } from '../shared/models/shelf';
import { Word } from '../shared/models/word';

export const shelfRoutes = express.Router();



Loading…
取消
儲存