greenlock-store-sequelize.js/README.md

109 lines
2.3 KiB
Markdown
Raw Normal View History

2019-04-18 03:06:45 +00:00
# [greenlock-store-sequelize][1]
> A database-driven Greenlock storage plugin with wildcard support.
## Usage
To use, provide this Greenlock storage plugin as the `store` attribute when you
invoke `create`.
```js
var store = require('le-store-sequelize');
var gl = greenlock.create({
store,
approveDomains,
...
});
```
## Wildcards & AltNames
Working with wildcards and multiple altnames requires Greenlock `>= v2.7`.
To do so you must set `opts.subject` and `opts.domains` within the
`approvedomains()` callback.
`subject` refers to "the subject of the ssl certificate" as opposed to `domain`
which indicates "the domain servername used in the current request". For
single-domain certificates they're always the same, but for multiple-domain
certificates `subject` must be the name no matter what `domain` is receiving a
request. `subject` is used as part of the name of the file storage path where
the certificate will be saved (or retrieved).
`domains` should be the list of "altnames" on the certificate, which should
include the `subject`.
## Example
```javascript
function approveDomains() {
}
```
2019-04-10 14:17:15 +00:00
## Configuration
2019-04-10 14:17:15 +00:00
### Defaults
No configuration is required. By default, you'll get a baked-in Sequelize
database running sqlite3.
```javascript
2019-04-10 14:17:15 +00:00
greenlock.create({
store: require('le-store-sequelize'),
...
});
```
2019-04-10 14:17:15 +00:00
### Database Connection
2019-04-10 14:11:38 +00:00
Without `config.dbOptions`, the baked-in sequelize object uses sqlite3 with
default options. If `config.dbOptions` is provided, you can configure the
database connection per the Sequelize documentation.
```javascript
var store = require('le-store-sequelize')({
dbConfig: {
username: 'mysqluser',
password: 'mysqlpassword',
database: 'mysqldatabase,
host: '127.0.0.1',
dialect: 'mysql'
}
});
greenlock.create({
2019-04-10 14:17:15 +00:00
store,
2019-04-10 14:11:38 +00:00
...
});
```
The database can also be configured using an env variable.
```javascript
var store = require('le-store-sequelize')({
dbConfig: {
use_env_variable: 'DB_URL'
}
});
```
2019-04-10 14:17:15 +00:00
### Custom Database Object
2019-04-10 14:20:34 +00:00
If you already have a Sequelize object, you can pass that in as `config.db`,
circumventing the baked-in database entirely.
2019-04-10 14:17:15 +00:00
```javascript
2019-04-10 14:20:34 +00:00
var db = require('./db');
2019-04-10 14:17:15 +00:00
var store = require('le-store-sequelize')({
db
});
2019-04-10 14:17:15 +00:00
greenlock.create({
store,
...
});
```
2019-04-18 03:06:45 +00:00
[1]: https://www.npmjs.com/package/greenlock-store-sequelize