Options
All
  • Public
  • Public/Protected
  • All
Menu

DAIS Internship Manager - Server

Index

Type aliases

Properties

Properties: object

A type used to query a mongoose entity

Type declaration

RepositoryQuery

RepositoryQuery: Properties<Dto> | Query<Dto> | object | object

The repository query request

Variables

Const CompanyModel

CompanyModel: Model<ICompany> = model<ICompany>("Company", CompanySchema, Defaults.collectionsName.companies)

The CompanyModel mongoose schema model

Const CompanySchema

CompanySchema: Schema = new Schema({name: String,address: {street: String,number: String,floor: String,city: String,zip: String,state: String,country: String},status: Number,vatCode: String,owners: [{type: Schema.Types.ObjectId,ref: 'User',autopopulate: true}],registrationDate: Date})

The Company mongoose schema

Const GooglePlusTokenStrategy

GooglePlusTokenStrategy: any = require('passport-google-plus-token')

Const InternshipModel

InternshipModel: Model<IInternship> = model<IInternship>("Internship", InternshipSchema, Defaults.collectionsName.internships)

The CompanyModel mongoose schema model

Const InternshipProposalModel

InternshipProposalModel: Model<IInternshipProposal> = model<IInternshipProposal>("InternshipProposal", InternshipProposalSchema, Defaults.collectionsName.internshipProposals)

The InternshipProposalModel mongoose schema model

Const InternshipProposalSchema

InternshipProposalSchema: Schema = new Schema({internship: {type: Schema.Types.ObjectId,ref: 'Internship',autopopulate: true},student: {type: Schema.Types.ObjectId,ref: 'User',autopopulate: true},professor: {type: Schema.Types.ObjectId,ref: 'User',autopopulate: true},creationDate: Schema.Types.Date,endDate: Schema.Types.Date,startDate: Schema.Types.Date,status: Schema.Types.Number,attendances: [{date: {type: Schema.Types.Date,required: true},hours: {type: Schema.Types.Number,required: true}}]})

The InternshipProposalSchema mongoose schema

Const InternshipSchema

InternshipSchema: Schema = new Schema({company: {type: Schema.Types.ObjectId,ref: 'Company',autopopulate: true},startDate: Date,endDate: Date,totalHours: Number,address: {street: String,number: String,floor: String,city: String,zip: String,state: String,country: String},description: String,title: String,tags: [{type: String}],studentsNumber: Number,status: {type: Number,required: true},rejectReason: String})

The [[Internship]] mongoose schema

Const PdfPrinter

PdfPrinter: any = require('pdfmake/src/printer')

Const RoleModel

RoleModel: Model<IRole> = model<IRole>("Role", RoleSchema, Defaults.collectionsName.roles)

The RoleModel mongoose schema model

Const RoleSchema

RoleSchema: Schema = new Schema({name: {type: String,unique: true},type: Number})

The Role mongoose schema

Const UserModel

UserModel: Model<IUser> = model<IUser>("User", UserSchema, Defaults.collectionsName.users)

The UserModel mongoose schema model

Const UserSchema

UserSchema: Schema = new Schema({name: String,email: {type: String,index: {unique: true},required: true},phone: [{type: String}],role: {type: Schema.Types.Mixed,ref: 'Role',autopopulate: true},birthDate: Date,registrationDate: Date,residenceAddress: {street: String,number: String,floor: String,city: String,zip: String,state: String,country: String},password: {type: String,required: false},googleId: {type: String,required: false},authType: {type: Number,enum: [AuthType.Local, AuthType.Google],required: true},image: String})

The User mongoose schema

Const app

app: Express = express()

Create Express server.

Const bcrypt

bcrypt: any = require('bcrypt')

Const container

container: Container = new Container()

The dependency injection global container

Const result

result: DotenvResult = dotenv.config({path: path.resolve(process.cwd(), `${process.env.NODE_ENV || 'development'}.env`)})

Functions

adminScope

  • adminScope(request: Request, response: Response, next: Function): any
  • Permit execution if and only if current JWT token owner has role.type Admin

    Parameters

    • request: Request

      The request with the populated body.__user

    • response: Response

      The response stream

    • next: Function

      The next middleware function

    Returns any

canExec

  • canExec(role: number | RoleType, requiredRoles: Array<RoleType>): boolean
  • Return true if the given role number has at least one requiredRoles or is an admin

    Parameters

    • role: number | RoleType

      The current logged in user role

    • requiredRoles: Array<RoleType>

      The required roles for the operation

    Returns boolean

canExecMw

  • canExecMw(...roles: Array<RoleType>): Promise<fun>

checkBodyUser

  • checkBodyUser(request: Request, response: Response): User
  • Check if the current request has a body property with the decoded JWT information. If this value exists and its 'role' property has value it gets returned, otherwise an auth error will be sent in the response stream.

    Parameters

    • request: Request

      The request

    • response: Response

      The response

    Returns User

companyScope

  • companyScope(request: Request, response: Response, next: Function): any
  • Permit execution if and only if current JWT token owner has role.type Company

    Parameters

    • request: Request

      The request with the populated body.__user

    • response: Response

      The response stream

    • next: Function

      The next middleware function

    Returns any

generateInternshipProposalTemplate

  • generateInternshipProposalTemplate(proposal: InternshipProposal): any

normalizeSchema

  • normalizeSchema(schema: Schema): Schema
  • Ensure returned object has property id instead of _id and __v

    Parameters

    • schema: Schema

      The schema to normalize

    Returns Schema

normalizeToJson

normalizeToObject

ownCompany

  • ownCompany(request: Request, response: Response, next: Function): Promise<any>
  • Parameters

    • request: Request
    • response: Response
    • next: Function

    Returns Promise<any>

ownInternship

  • ownInternship(request: Request, response: Response, next: Function): Promise<any>
  • Parameters

    • request: Request
    • response: Response
    • next: Function

    Returns Promise<any>

ownInternshipProposal

  • ownInternshipProposal(request: Request, response: Response, next: Function): Promise<any>
  • Parameters

    • request: Request
    • response: Response
    • next: Function

    Returns Promise<any>

professorScope

  • professorScope(request: Request, response: Response, next: Function): any
  • Permit execution if and only if current JWT token owner has role.type Professor

    Parameters

    • request: Request

      The request with the populated body.__user

    • response: Response

      The response stream

    • next: Function

      The next middleware function

    Returns any

studentScope

  • studentScope(request: Request, response: Response, next: Function): any
  • Permit execution if and only if current JWT token owner has role.type Student

    Parameters

    • request: Request

      The request with the populated body.__user

    • response: Response

      The response stream

    • next: Function

      The next middleware function

    Returns any

Object literals

Const environment

environment: object

The application environment

connectionString

connectionString: string = process.env.dbConnectionString

The mongoose connection string

isDebug

isDebug: boolean = true

If the current application is in debug mode

jwtSecret

jwtSecret: string = process.env.jwtSecret

The JSON Web Token secret

email

email: object

The emails configuration

host

host: null = null

port

port: null = null

service

service: string = process.env.emailService

auth

auth: object

password

password: string = process.env.emailPassword

user

user: string = process.env.emailUser

googleOAuth

googleOAuth: object

The Google OAuth config

clientId

clientId: string = process.env.googleOAuthClientId

clientSecret

clientSecret: string = process.env.googleOAuthClientSecret

Const types

types: object

The Dependency Injection symbols (used to inject interfaces)

App

App: symbol = Symbol.for("App")

The express application

Models

Models: object

The mongoose schema models

Company

Company: symbol = Symbol.for("CompanyModel")

InternShip

InternShip: symbol = Symbol.for("InternShipModel")

InternShipProposal

InternShipProposal: symbol = Symbol.for("InternShipProposalModel")

Role

Role: symbol = Symbol.for("RoleModel")

User

User: symbol = Symbol.for("UserModel")

Generated using TypeDoc