Home Reference Source Repository

References

Class Summary

Static Public Class Summary
public

This class allows for easy building of a request to the API.

Function Summary

Static Public Function Summary
public

async changeEmail(email: string, storedPassword: string, password: string, newEmail: string): Promise<undefined, Error>

Delete all of user's sessions from database and change their email.

public

async changePassword(email: string, storedPassword: string, password: string, newPassword: string): Promise<undefined, Error>

Delete all of user's sessions from database and change their password.

public

Closes the connection from mongoose to the database, using unmock if NODE_ENV is 'test'.

public

Helper method to check users password

public

Utility function to compare against a bcrypt'd password.

public

createEvent(newEvent: EventSchema): Promise<string, Error

Creates a new event on the server

public

createEvent(reqData: Object, locals: Object, createCallback: EventCallback)

Creates a event using fields from the request object then calls back when the database save finishes.

public

createReport(reqData: Object, locals: Object, createCallback: reportCallback)

Creates a report with the fields in the request object, and calls a callback when the database save finishes.

public

createReport(newReport: Object): Promise<string, Error

Creates a new report on the server

public

Given User information, create a User.

public

Creates a new user on the server

public

deleteEvent(eventUid: string, locals: Object, deleteCallback: EventCallback)

Deletes a specific event and calls back once database deletion finishes.

public

deleteReport(reportUid: string, locals: Object, deleteCallback: reportCallback)

Deletes a specific report, and calls a callback once the database deletion finishes.

public

Utility function to delete all sessions for a given user's email.

public

Deletes a user from the server

public

deleteUser(userUid: string, locals: Object, deleteCallback: DeleteUserCallback)

Deletes the user from the database.

public

Handles errors from API and logs them

public

getAllEvents(): Promise<Object, Error

Retrieves all events from the server.

public

getAllReports(): Promise<Object, Error

Retrieves all reports from the server.

public

getAllReports(reqData: Object, locals: Object, queryCallback: multipleReportsCallback)

Finds all reports, and calls a callback once all reports are found.

public

async getCollection(connection: string, name: string): Promise<Object, Error>

Utility function to get a MongoClient collection instance from Mongoose.

public

getEvent(uid: string): Promise<EventSchema, Error

Retrieves an event from the server by its UID

public

getEventById(eventUid: string, locals: Object, getCallback: EventCallback)

Finds a specific event and calls back once find operation finishes.

public

getReport(uid: string): Promise<Object, Error

Retrieves an report from the server by its UID

public

getReportById(reportUid: string, locals: Object, queryCallback: reportCallback)

Finds a specific report, and calls a callback once the report is found.

public

getUser(userUid: string): Promise<userSchema, Error>

Retrieves a user from the server

public

getUserById(userUid: string, locals: Object, queryCallback: GetUserCallback)

Retrieves the user.

public

async login(req: Object, res: Object): Promise<string, Error>

Given a valid email/password, generates a session and returns the id.

public

login(email: String, password: String): Promise<Object, Error>

Attempt to login using email and password.

public

async logout(session: Object): Promise<undefined, Error>

Delete a specific session from the database.

public

Attempt to logout.

public

modifyEvent(event: string, reqData: Object, locals: Object, modifyCallback: EventCallback)

Modifies a specific event with the fields in the request object then calls back when the database update finishes.

public

Modifies an event on the server.

public

modifyReport(reportUid: string, reqData: Object, locals: Object, modifyCallback: reportCallback)

Modifies a specific report according to the fields in the request object, and calls a callback when the database save finishes.

public

modifyReport(uid: string, updatedReport: Object): Promise<Object, Error>

Modifies an report on the server.

public

modifyUser(userUid: string, reqData: Object, locals: Object, modifyCallback: ModifyUserCallback)

Updates the user with the passed in values.

public

Modifies a user on the server

public

newIfPresent(newValue: T, oldValue: T): T

If the new value is defined and non-null, returns the new value.

public

Opens a connection from mongoose to the database, wrapping it with mockgoose if NODE_ENV is 'test'.

public

Removes an event on the server.

public

Removes an report on the server.

public

verify(req: Object, res: Object, next: function)

Middleware to determine whether the session is verified.

Variable Summary

Static Public Variable Summary
public

instance(baseURL: string, timeout: number): *

The connection information for the server hosting the API.

Typedef Summary

Static Public Typedef Summary
public

Logging tool for API

public

Callback for createUser

public

Callback for deleteUser

public

EventSchema(creator: string, category: string, datetime: Date, location: string, title: string, description: string): Object

Event Object

public

GetUserCallback(-: Object, -: UserSchemas): Object

Callback for getUserById

public

Callback for modifyUser

public

Promise callback for when API call finishes

public

Route for creating a new event

  • Endpoint: /api/events
  • Verb: POST
public

Route for creating a new event

  • Endpoint: /api/events
  • Verb: POST
public

Route for creating a new report

  • Endpoint: /api/reports
  • Verb: POST
public

Route for creating a new report

  • Endpoint: /api/reports
  • Verb: POST
public

Route for creating a new user

API

  • Endpoint: /api/users
  • Verb: POST
  • Success Code: 201
public

Route for creating a new user

API

  • Endpoint: /api/users
  • Verb: POST
  • Success Code: 201
public

Route for deleting an existing event

API

  • Endpoint: /api/events
  • Verb: DELETE
public

Route for deleting an existing event

  • Endpoint: /api/reports
  • Verb: DELETE
public

Route for deleting an existing user

API

  • Endpoint: /api/users
  • Verb: DELETE
  • Success Code: 200
public

Route for retrieving all events

API

  • Endpoint: /api/events/all
  • Verb: GET
public

Route for retrieving a single, existing event by its UID

  • Endpoint: /api/events
  • Verb: GET
public

Route for retrieving a single, existing event by its UID

  • Endpoint: /api/reports
  • Verb: GET
public

Route for getting an existing user

API

  • Endpoint: /api/users
  • Verb: GET
  • Success Code: 200
public

Route for modifying an existing event

  • Endpoint: /api/events
  • Verb: PUT
public

Route for modifying an existing report

  • Endpoint: /api/reports
  • Verb: POST
public

Route for modiying an existing user

API

  • Endpoint: /api/users
  • Verb: PUT
  • Success Code: 200
public

UserSchema(name: string, firstName: string, lastName: string, email: string, password: string, role: string, isApproved: boolean): Object

User Object