Bläddra i källkod

moved models to src and made individual model files for equivalent mongo collection

master
kj1352 4 år sedan
förälder
incheckning
7b4daf185d
8 ändrade filer med 76 tillägg och 51 borttagningar
  1. +0
    -50
      models/user.ts
  2. +9
    -0
      src/models/category.ts
  3. +16
    -0
      src/models/library.ts
  4. +20
    -0
      src/models/shelf.ts
  5. +11
    -0
      src/models/user.ts
  6. +3
    -0
      src/models/variables.ts
  7. +16
    -0
      src/models/word.ts
  8. +1
    -1
      src/user-profile/routes.ts

+ 0
- 50
models/user.ts Visa fil

@@ -1,50 +0,0 @@
export type IWord = {
name: string,
pronounciation: {
text: string,
audio: string, // URL for the audio file
},
similarWords: Array<IWord>,
gramaticalDetails: Array<{
type: 'NOUN' | 'PRONOUN' | 'ADJECTIVE' | 'VERB' | 'ADVERB' | 'PREPOSITION' | 'CONJUNCTION' | 'INTERJECTION',
description: string,
examples: Array<string>,
}>
}

export type IShelf = {
name: string,
description: string,
viewType: 'PUBLIC' | 'PRIVATE' | 'FRIENDS' | 'FOLLOWERS',
isArchived: boolean,
addedWords: Array<{
word: IWord,
notes: Array<string>,
isFavourite: boolean,
nextRevisionDateTime: Date,
revisionHistory : Array<{
day: Date,
wasRecallSuccessful: boolean,
}>
}>
}

export type ICategory = {
name: string,
icon: string,
shelves: Array<IShelf>,
isArchived: boolean,
}

export type IUser = {
// For Auth purposes
_id: string,
name: string,
email: string,
password: string,
isVerified: boolean,
otp: number,

// Other records
categories: Array<ICategory>
}

+ 9
- 0
src/models/category.ts Visa fil

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

export interface Category {
_id: string,
name: string,
icon: string,
shelves: Array<Shelf>,
isArchived: boolean,
}

+ 16
- 0
src/models/library.ts Visa fil

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

export interface Library {
_id: string,
languageType: LanguageType,
isArchived: boolean,
allWords: Array<{
word: Word,
isArchived: boolean,
wordStats: {
favouriteCount: number, // Total users who liked this word
addCount: number, // Total users have added this word to their shelf
}
}>,
}

+ 20
- 0
src/models/shelf.ts Visa fil

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

export interface Shelf {
_id: string,
name: string,
description: string,
viewType: viewPermissionType,
isArchived: boolean,
addedWords: Array<{
word: Word,
notes: Array<string>,
isFavourite: boolean,
nextRevisionDateTime: Date,
revisionHistory : Array<{
day: Date,
wasRecallSuccessful: boolean,
}>
}>
}

+ 11
- 0
src/models/user.ts Visa fil

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

export type IUser = {
_id: string,
name: string,
email: string,
password: string,
isVerified: boolean,
otp: number,
categories: Array<Category>,
}

+ 3
- 0
src/models/variables.ts Visa fil

@@ -0,0 +1,3 @@
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';

+ 16
- 0
src/models/word.ts Visa fil

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

export interface Word {
_id: string,
name: string,
pronounciation: {
text: string,
audio: string,
},
similarWords: Array<Word>,
grammaticalDetails: Array<{
type: grammarType,
description: string,
examples: Array<string>,
}>
}

+ 1
- 1
src/user-profile/routes.ts Visa fil

@@ -1,6 +1,6 @@
import express from 'express';
import passport from 'passport';
import { IUser } from '../../models/user';
import { IUser } from '../models/user';

export const userProfileRoutes = express.Router();



Laddar…
Avbryt
Spara