API Specification
Modules
- boilerplate
- models
Model definitions.
boilerplate
- boilerplate
- ~settings :
object
- ~databaseSettings :
object
- ~watchIgnoreFiles
- ~nunjucksMiddleware(app) ⇒
function
- ~sleep(ms)
- ~createDatabaseIfNotExists(dbname)
- ~dropDatabaseIfExists(dbname)
- ~initSequelize() ⇒
Sequelize
- ~loadModels(sequelize) ⇒
object
- ~syncDatabase(sequelize)
- ~buildExpressApp() ⇒
object
- ~startServer()
- ~startShell()
- ~settings :
boilerplate~settings : object
The settings Express.js uses to serve HTTP
Kind: inner constant of boilerplate
Properties
Name | Type | Description |
---|---|---|
port | number | The port the server binds to |
boilerplate~databaseSettings : object
The connection parameters for connecting to the database.
Kind: inner constant of boilerplate
Properties
Name | Type | Description |
---|---|---|
database | string | Overridable via PGDATABASE |
username | string | Overridable via PGUSER |
password | string | Overridable via PGPASSWORD |
host | string | Overridable 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
Param | Type | Description |
---|---|---|
app | Express | The express app you're adding things to. |
boilerplate~sleep(ms)
Sleeps.
Kind: inner method of boilerplate
Param | Type | Description |
---|---|---|
ms | integer | How many milliseconds to sleep for. |
boilerplate~createDatabaseIfNotExists(dbname)
Creates a database on the database server if it exists.
Kind: inner method of boilerplate
Param | Type | Description |
---|---|---|
dbname | string | The name of the database to create |
boilerplate~dropDatabaseIfExists(dbname)
Drops a database from the database server if it exists.
Kind: inner method of boilerplate
Param | Type | Description |
---|---|---|
dbname | string | The 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
Param | Type | Description |
---|---|---|
sequelize | Sequelize | The Sequelize instance to use |
boilerplate~syncDatabase(sequelize)
Ensures the database tables match the models.
Kind: inner method of boilerplate
Param | Type | Description |
---|---|---|
sequelize | Sequelize | The 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
- .setPassword(v)
- .passwordMatches(v) ⇒
boolean
- ~Address ⇐
sequelize.Model
- instance
- .stringValue() ⇒
string
- .getCoordinates() ⇒
object
- .stringValue() ⇒
- static
- .geocode(addressString) ⇒
object
- .geocode(addressString) ⇒
- instance
- ~ToolMaker ⇐
sequelize.Model
- ~ToolCategory ⇐
sequelize.Model
- ~Tool ⇐
sequelize.Model
- ~Listing ⇐
sequelize.Model
- ~UserMessage ⇐
sequelize.Model
- ~UserReviews ⇐
sequelize.Model
- ~FileUpload
- ~User ⇐
models~User ⇐ sequelize.Model
Represents a user.
Kind: inner class of models
Extends: sequelize.Model
Properties
Name | Type | Description |
---|---|---|
first_name | string | The user's first name |
last_name | string | The user's last name |
string | The user's email, used for logging in | |
password_hash | string | A hashed version of the user's password using bcrypt. Not to be set directly, use setPassword and passwordMatches(). |
address_id | int | The ID of an Address record for the user. |
billing_address_id | int | The ID of an Address record for the user. |
- ~User ⇐
sequelize.Model
- .setPassword(v)
- .passwordMatches(v) ⇒
boolean
user.setPassword(v)
Sets a user's password.
Kind: instance method of User
Param | Type | Description |
---|---|---|
v | string | The 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.
Param | Type | Description |
---|---|---|
v | string | The password to test |
models~Address ⇐ sequelize.Model
Represents an address.
Kind: inner class of models
Extends: sequelize.Model
Properties
Name | Type | Description |
---|---|---|
line_two | string | |
city | string | |
state | string | The state of the address, should be a 2-digit uppercase value like "NJ" or "PA" |
zip_code | string | |
geocoded | bool | Whether or not the address has been geocoded yet |
geocoded_lat | double | the latitude value from geocoding - not user set |
geocoded_lon | double | the longitude value from geocoding - not user set |
- ~Address ⇐
sequelize.Model
- instance
- .stringValue() ⇒
string
- .getCoordinates() ⇒
object
- .stringValue() ⇒
- static
- .geocode(addressString) ⇒
object
- .geocode(addressString) ⇒
- instance
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}
)
Param | Type | Description |
---|---|---|
addressString | string | An 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
Name | Type | Description |
---|---|---|
name | string | The name of the manufacturer |
searchVector | string | TSVector, 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
Name | Type | Description |
---|---|---|
name | string | The name of the category |
searchVector | string | TSVector, 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
Name | Type | Description |
---|---|---|
name | string | Name of the tool. |
description | string | An arbitrary description of the tool and its condition. |
searchVector | ts_vector | A representation of a bunch of text related to the tool that's used with fulltext search. |
owner_id | integer | The id of the User record that owns this tool |
tool_category_id | integer | The id the category related to this tool |
tool_maker_id | integer | The id of the maker of this tool. |
video | string | YouTube 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
Name | Type | Description |
---|---|---|
price | number | The amount the listing costs per billingInterval |
billingInterval | string | The interval at which you're going to pay price |
maxBillingIntervals | integer | The 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
Name | Type | Description |
---|---|---|
content | string | Message content |
recipient_id | int | The ID of the recipient User model |
sender_id | int | The ID of the sending User model |
listing_id | int | The 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
Name | Type | Description |
---|---|---|
content | text | The contents of the review |
ratings | integer | The star ratings of another user |
reviewee_id | integer | |
reviewer_id | integer |
models~FileUpload
Kind: inner class of models
Classdescription: Represents a file that's uploaded.
Properties
Name | Type | Description |
---|---|---|
path | string | Path of file, relative to uploads directory |
originalName | string | Original name of the file, as appearing on the uploader's computer |
size | integer | Size of the file in bytes |
mimeType | string | The mimetype of the file |
uploader_id | integer | The ID of the uploader |