Skip to main content

API Specification

Modules

boilerplate
models

Model definitions.

boilerplate

boilerplate~settings : object

The settings Express.js uses to serve HTTP

Kind: inner constant of boilerplate
Properties

NameTypeDescription
portnumberThe port the server binds to

boilerplate~databaseSettings : object

The connection parameters for connecting to the database.

Kind: inner constant of boilerplate
Properties

NameTypeDescription
databasestringOverridable via PGDATABASE
usernamestringOverridable via PGUSER
passwordstringOverridable via PGPASSWORD
hoststringOverridable via PGHOST

boilerplate~watchIgnoreFiles

List of files to avoid watching.

Kind: inner constant of boilerplate

boilerplate~nunjucksMiddleware(app) ⇒ function

Create middleware to render nunjucks templates.

Kind: inner method of boilerplate
Returns: function - Middleware function

ParamTypeDescription
appExpressThe express app you're adding things to.

boilerplate~sleep(ms)

Sleeps.

Kind: inner method of boilerplate

ParamTypeDescription
msintegerHow many milliseconds to sleep for.

boilerplate~createDatabaseIfNotExists(dbname)

Creates a database on the database server if it exists.

Kind: inner method of boilerplate

ParamTypeDescription
dbnamestringThe name of the database to create

boilerplate~dropDatabaseIfExists(dbname)

Drops a database from the database server if it exists.

Kind: inner method of boilerplate

ParamTypeDescription
dbnamestringThe name of the database to drop

boilerplate~initSequelize() ⇒ Sequelize

Initializes a sequelize instance. Loads models and syncs the database schema.

Kind: inner method of boilerplate
Returns: Sequelize - An instance of Sequelize that's ready to use.

boilerplate~loadModels(sequelize) ⇒ object

Loads model definitions

Kind: inner method of boilerplate
Returns: object - The models defined

ParamTypeDescription
sequelizeSequelizeThe Sequelize instance to use

boilerplate~syncDatabase(sequelize)

Ensures the database tables match the models.

Kind: inner method of boilerplate

ParamTypeDescription
sequelizeSequelizeThe Sequelize instance to use

boilerplate~buildExpressApp() ⇒ object

Builds an expressjs app

Kind: inner method of boilerplate
Returns: object - An Express.js app

boilerplate~startServer()

Starts the Express.js HTTP server.

Kind: inner method of boilerplate

boilerplate~startShell()

Starts the Sequelize shell

Kind: inner method of boilerplate

models

Model definitions.

models~User ⇐ sequelize.Model

Represents a user.

Kind: inner class of models
Extends: sequelize.Model
Properties

NameTypeDescription
first_namestringThe user's first name
last_namestringThe user's last name
emailstringThe user's email, used for logging in
password_hashstringA hashed version of the user's password using bcrypt. Not to be set directly, use setPassword and passwordMatches().
address_idintThe ID of an Address record for the user.
billing_address_idintThe ID of an Address record for the user.

user.setPassword(v)

Sets a user's password.

Kind: instance method of User

ParamTypeDescription
vstringThe user's new password.

user.passwordMatches(v) ⇒ boolean

Determines if a given password matches a user's password.

Kind: instance method of User
Returns: boolean - Whether or not the password matched.

ParamTypeDescription
vstringThe password to test

models~Address ⇐ sequelize.Model

Represents an address.

Kind: inner class of models
Extends: sequelize.Model
Properties

NameTypeDescription
line_twostring
citystring
statestringThe state of the address, should be a 2-digit uppercase value like "NJ" or "PA"
zip_codestring
geocodedboolWhether or not the address has been geocoded yet
geocoded_latdoublethe latitude value from geocoding - not user set
geocoded_londoublethe longitude value from geocoding - not user set

address.stringValue() ⇒ string

Returns a string representing the address.

Kind: instance method of Address
Returns: string - A string representing the address, suitable for display or geocoding.

address.getCoordinates() ⇒ object

Gets coordinates for the address.

Kind: instance method of Address
Returns: object - coordinate The coordinate the address geocodes to ({lat, lon})

Address.geocode(addressString) ⇒ object

Gets coordinates for a string address.

Kind: static method of Address
Returns: object - coordinate The coordinate the address geocodes to ({lat, lon})

ParamTypeDescription
addressStringstringAn address in string form, similar to but not necessarily formatted like "123 Example Street, Exampleton, CA 12345"

models~ToolMaker ⇐ sequelize.Model

Represents a manufacturer of tools, like Milwaukee or DeWalt.

Kind: inner class of models
Extends: sequelize.Model
Properties

NameTypeDescription
namestringThe name of the manufacturer
searchVectorstringTSVector, not to be used in JavaScript code (DB-side only)

models~ToolCategory ⇐ sequelize.Model

Represents a kind of tool - like hammer, saw, or drill.

Kind: inner class of models
Extends: sequelize.Model
Properties

NameTypeDescription
namestringThe name of the category
searchVectorstringTSVector, not to be used in JavaScript code (DB-side only)

models~Tool ⇐ sequelize.Model

Represents an individual tool, like the drill in your garage, or your neighbor's drill press.

Kind: inner class of models
Extends: sequelize.Model
Properties

NameTypeDescription
namestringName of the tool.
descriptionstringAn arbitrary description of the tool and its condition.
searchVectorts_vectorA representation of a bunch of text related to the tool that's used with fulltext search.
owner_idintegerThe id of the User record that owns this tool
tool_category_idintegerThe id the category related to this tool
tool_maker_idintegerThe id of the maker of this tool.
videostringYouTube video attached to a tool

models~Listing ⇐ sequelize.Model

Represents a tool's being listed for sale.

Kind: inner class of models
Extends: sequelize.Model
Properties

NameTypeDescription
pricenumberThe amount the listing costs per billingInterval
billingIntervalstringThe interval at which you're going to pay price
maxBillingIntervalsintegerThe maximum number of billing intervals the tool is available for.

models~UserMessage ⇐ sequelize.Model

Represents a conversation between two users.

Kind: inner class of models
Extends: sequelize.Model
Properties

NameTypeDescription
contentstringMessage content
recipient_idintThe ID of the recipient User model
sender_idintThe ID of the sending User model
listing_idintThe ID of the listing this message was sent about.

models~UserReviews ⇐ sequelize.Model

Kind: inner class of models
Extends: sequelize.Model
Classdescription: Represents reviews and ratings of other users
Properties

NameTypeDescription
contenttextThe contents of the review
ratingsintegerThe star ratings of another user
reviewee_idinteger
reviewer_idinteger

models~FileUpload

Kind: inner class of models
Classdescription: Represents a file that's uploaded.
Properties

NameTypeDescription
pathstringPath of file, relative to uploads directory
originalNamestringOriginal name of the file, as appearing on the uploader's computer
sizeintegerSize of the file in bytes
mimeTypestringThe mimetype of the file
uploader_idintegerThe ID of the uploader
Provide feedback