Skip to content
Snippets Groups Projects
Commit 02e25d85 authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

refactor documentations and update CardImage schema

parent d2ae8ec4
Branches
No related tags found
2 merge requests!27refresh dev branch,!26Feature/refactor
Pipeline #5628 passed
Showing
with 3 additions and 63 deletions
...@@ -11,12 +11,8 @@ import axios from "axios"; ...@@ -11,12 +11,8 @@ import axios from "axios";
* to get the logged in Users data. * to get the logged in Users data.
* If the user is registered, then the Profile object * If the user is registered, then the Profile object
* id from the database will be added to session.profile.id * id from the database will be added to session.profile.id
*
* @param {Request} req
* @param {Response} res
* @return {*} Redirects to the REDIRECT_URI
*/ */
const complete = (): any => async (req: Request, res: Response) => { const complete = () => async (req: Request, res: Response) => {
const tokenConfig = { const tokenConfig = {
code: String(req.query.code), code: String(req.query.code),
scope: scope, scope: scope,
......
...@@ -3,10 +3,6 @@ import { NextFunction, Request, Response } from "express"; ...@@ -3,10 +3,6 @@ import { NextFunction, Request, Response } from "express";
/** /**
* Middleware to check if the user * Middleware to check if the user
* is authenticated and registered * is authenticated and registered
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/ */
const isAuthenticated = () => ( const isAuthenticated = () => (
req: Request, req: Request,
......
...@@ -7,9 +7,6 @@ const authorizationUri = oauth2().authorizationCode.authorizeURL({ ...@@ -7,9 +7,6 @@ const authorizationUri = oauth2().authorizationCode.authorizeURL({
/** /**
* Redirects to the authorization URL * Redirects to the authorization URL
*
* @param {Request} req
* @param {Response} res
*/ */
const login = () => (req: Request, res: Response) => const login = () => (req: Request, res: Response) =>
res.redirect(authorizationUri); res.redirect(authorizationUri);
......
...@@ -2,9 +2,6 @@ import { Request, Response } from "express"; ...@@ -2,9 +2,6 @@ import { Request, Response } from "express";
/** /**
* Logs out the user by destroying the session * Logs out the user by destroying the session
*
* @param {Request} req
* @param {Response} res
*/ */
const logout = () => async (req: Request, res: Response) => { const logout = () => async (req: Request, res: Response) => {
await req.session!.destroy(() => console.log("user logged out.")); await req.session!.destroy(() => console.log("user logged out."));
......
...@@ -4,10 +4,6 @@ import { oauth2 } from "../../utils/auth"; ...@@ -4,10 +4,6 @@ import { oauth2 } from "../../utils/auth";
/** /**
* Refresh user accessToken * Refresh user accessToken
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/ */
const refreshToken = () => async ( const refreshToken = () => async (
req: Request, req: Request,
......
...@@ -13,10 +13,6 @@ const fields = [ ...@@ -13,10 +13,6 @@ const fields = [
* Middleware that creates a Card * Middleware that creates a Card
* from the request body and sets * from the request body and sets
* res.data.card to the created Card. * res.data.card to the created Card.
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/ */
const addCard = () => async ( const addCard = () => async (
req: Request, req: Request,
......
...@@ -6,10 +6,6 @@ import Card from "../../models/CardSchema"; ...@@ -6,10 +6,6 @@ import Card from "../../models/CardSchema";
* Middleware to find the card with * Middleware to find the card with
* id = req.params.id * id = req.params.id
* and set res.data.card * and set res.data.card
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/ */
const getCard = () => async ( const getCard = () => async (
req: Request, req: Request,
......
...@@ -5,10 +5,6 @@ import Card from "../../models/CardSchema"; ...@@ -5,10 +5,6 @@ import Card from "../../models/CardSchema";
/** /**
* Middleware to find all cards * Middleware to find all cards
* and set res.data.cards * and set res.data.cards
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/ */
const getCardList = () => async ( const getCardList = () => async (
req: Request, req: Request,
......
...@@ -6,10 +6,6 @@ import Card from "../../models/CardSchema"; ...@@ -6,10 +6,6 @@ import Card from "../../models/CardSchema";
* Middleware to find all * Middleware to find all
* not expired cards * not expired cards
* and set res.data.cards * and set res.data.cards
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/ */
const getCardListValid = () => async ( const getCardListValid = () => async (
req: Request, req: Request,
......
...@@ -2,10 +2,6 @@ import { Request, Response } from "express"; ...@@ -2,10 +2,6 @@ import { Request, Response } from "express";
/** /**
* Return the found card from res.data.card * Return the found card from res.data.card
*
* @param {Request} req
* @param {Response} res
* @return {*} Found Card or 404
*/ */
const responseCard = (): any => (req: Request, res: Response) => { const responseCard = (): any => (req: Request, res: Response) => {
if (!res.data.card) if (!res.data.card)
......
...@@ -2,10 +2,6 @@ import { Request, Response } from "express"; ...@@ -2,10 +2,6 @@ import { Request, Response } from "express";
/** /**
* Return the found card from res.data.cards * Return the found card from res.data.cards
*
* @param {Request} req
* @param {Response} res
* @return {*} Found Cards
*/ */
const responseCardList = (): any => (req: Request, res: Response) => { const responseCardList = (): any => (req: Request, res: Response) => {
return res.json(res.data.cards); return res.json(res.data.cards);
......
...@@ -5,10 +5,6 @@ import CardImage from "../../../models/CardImageSchema"; ...@@ -5,10 +5,6 @@ import CardImage from "../../../models/CardImageSchema";
/** /**
* Get the Entry card background image * Get the Entry card background image
* and set res.data.cardImage * and set res.data.cardImage
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/ */
const getCardImage = () => async ( const getCardImage = () => async (
req: Request, req: Request,
......
...@@ -6,11 +6,6 @@ import fs from "fs"; ...@@ -6,11 +6,6 @@ import fs from "fs";
/** /**
* Generate Entry card svg from Users data and card * Generate Entry card svg from Users data and card
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
* @return {*} Generated svg file
*/ */
const getUserCard = (): any => async ( const getUserCard = (): any => async (
req: Request, req: Request,
......
...@@ -4,10 +4,6 @@ import File from "../../../models/FileSchema"; ...@@ -4,10 +4,6 @@ import File from "../../../models/FileSchema";
/** /**
* Return the Entry card background Image * Return the Entry card background Image
*
* @param {Request} req
* @param {Response} res
* @return {*} The Found CardImage or the default
*/ */
const responseCardImage = (): any => async (req: Request, res: Response) => { const responseCardImage = (): any => async (req: Request, res: Response) => {
if (!res.data.cardImage) if (!res.data.cardImage)
......
...@@ -6,11 +6,6 @@ import fs from "fs"; ...@@ -6,11 +6,6 @@ import fs from "fs";
/** /**
* Upload a new Card background Image * Upload a new Card background Image
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
* @return {*} 200 Status code if uploaded
*/ */
const uploadCardImage = () => async ( const uploadCardImage = () => async (
req: Request, req: Request,
......
import { Document, Schema, model } from "mongoose"; import { Document, Schema, model } from "mongoose";
export interface ICardImage extends Document { export interface ICardImage extends Document {
imageId: Number; imageId: String;
} }
const CardImageSchema = new Schema({ const CardImageSchema = new Schema({
imageId: { type: Schema.Types.ObjectId, ref: "File", required: false }, imageId: { type: Schema.Types.ObjectId, ref: "File", required: true },
}); });
export default model<ICardImage>("CardImage", CardImageSchema); export default model<ICardImage>("CardImage", CardImageSchema);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment