Skip to content

Commit

Permalink
Merge pull request #32 from piuswalter/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
piuswalter authored Sep 14, 2021
2 parents d504a0a + f8909b0 commit 15e9d9b
Show file tree
Hide file tree
Showing 23 changed files with 33,020 additions and 10,721 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Files from SonarScanner analysis
.scannerwork/
4,872 changes: 4,522 additions & 350 deletions backend/package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@
}
],
"dependencies": {
"axios": "^0.21.1",
"axios": "^0.21.4",
"body-parser": "^1.19.0",
"cheerio-htmlparser2": "^1.0.3",
"dotenv": "^8.2.0",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"swagger-jsdoc": "^6.0.0-rc.5",
"swagger-ui-express": "^4.1.5",
"swagger-jsdoc": "^6.1.0",
"swagger-ui-express": "^4.1.6",
"winston": "^3.3.3"
},
"devDependencies": {
"@types/express": "^4.17.9",
"@types/swagger-jsdoc": "^3.0.2",
"@types/swagger-ui-express": "^4.1.2",
"@typescript-eslint/eslint-plugin": "^4.10.0",
"@typescript-eslint/parser": "^4.10.0",
"eslint": "^7.16.0",
"@types/express": "^4.17.13",
"@types/swagger-jsdoc": "^6.0.1",
"@types/swagger-ui-express": "^4.1.3",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
"eslint-plugin-import": "^2.24.2",
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
}
}
10 changes: 10 additions & 0 deletions backend/src/routes/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ export async function getFlashcards(req: Request, res: Response, next: NextFunct
next(error);
}
}

export async function getTags(req: Request, res: Response, next: NextFunction) {
try {
const { token, params: { userId, subjectId } } = req as any;
const json = await studysmarterService.getTags(userId, subjectId, token);
res.send(json.data);
} catch (error) {
next(error);
}
}
56 changes: 53 additions & 3 deletions backend/src/routes/users/users.router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router } from 'express';
import { getSubjects, getFlashcards } from './users.controller';
import { getSubjects, getFlashcards, getTags } from './users.controller';

export default (router: Router) => {
const userRouter = Router();
Expand All @@ -10,7 +10,7 @@ export default (router: Router) => {
* get:
* tags:
* - Subjects
* summary: get subjects from specific user
* summary: get subjects from specified user
* security:
* - token: []
* parameters:
Expand Down Expand Up @@ -51,7 +51,7 @@ export default (router: Router) => {
* get:
* tags:
* - Flashcards
* summary: get flashcards from specific subject and user
* summary: get flashcards from specified subject and user
* security:
* - token: []
* parameters:
Expand Down Expand Up @@ -124,5 +124,55 @@ export default (router: Router) => {
*/
userRouter.get('/:userId/subjects/:subjectId/flashcards', getFlashcards);

/**
* @swagger
* /users/{userId}/subjects/{subjectId}/tags:
* get:
* tags:
* - Tags
* summary: get tags from specified subject and user
* security:
* - token: []
* parameters:
* - in: path
* name: userId
* description: ID of the user
* required: true
* schema:
* type: string
* - in: path
* name: subjectId
* description: ID of the subject
* required: true
* schema:
* type: string
* responses:
* "200":
* description: list of tags
* content:
* application/json:
* schema:
* type: array
* items:
* type: object
* properties:
* id:
* type: integer
* description: tag ID
* name:
* type: string
* description: name of the tag
* colour:
* type: number
* description: color of the tag
* subject:
* type: number
* description: subject ID of the tag
* creator:
* type: number
* description: creator of the tag
*/
userRouter.get('/:userId/subjects/:subjectId/tags', getTags);

router.use('/users', userRouter);
};
4 changes: 4 additions & 0 deletions backend/src/utils/studysmarter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ export async function getFlashcards(userId: string, subjectId: string, apiToken:
return request<StudySmarterResponse<Flashcard>>('get', `users/${userId}/subjects/${subjectId}/flashcards/?quantity=99999&s_bad=true&s_medium=true&s_good=true&s_trash=true&s_unseen=true&order=anti-chronological`, null, { authorization: `Token ${apiToken}` });
}
// &created_by=

export async function getTags(userId: string, subjectId: string, apiToken: string) {
return request<StudySmarterResponse<Subject>>('get', `users/${userId}/subjects/${subjectId}/tags/`, null, { authorization: `Token ${apiToken}` });
}
Loading

0 comments on commit 15e9d9b

Please sign in to comment.