Releases: dadi/api
v1.15.1
Version 1.15.0
- Improved SSL handling
- Integrated @dadi/cache module in place of custom caching
- Add media upload functionality
- Fully tested against Node versions 4.7.0, 5.12.0, 6.9.2
Version 1.14.1
This release fixes a bug where collection and endpoint files were given an incorrect REST resource address. This was caused by splitting the directory path to the files using the character '/', which fails under Windows. The update uses the appropriate separator for the platform by calling Node's built in path.sep
method.
Version 1.14.0
Version 1.14.0 includes the following additions and changes.
- Added:
matchType
property added to fields in collection schemas. Determines the type of match allowed when querying using this field.
Example
"fields": {
"title": {
"type": "String",
"required": true,
"matchType": "exact"
},
"author": {
"type": "Reference",
"settings": {
"collection": "person"
}
},
"booksInSeries": {
"type": "Reference"
}
}
Possible values
Value | Behaviour |
---|---|
"exact" | query will be performed using the exact value specified, e.g. { "publishedState": "published" } |
"ignoreCase" | query will be performed using a case insensitive regex of the value specified, e.g. { "publishedState": /^published$/i } |
"anything else" | query will be performed using a regex of the value specified, e.g. { "publishedState": /^published$/ } |
Note: If
matchType
is not specified, the default (for legacy reasons) is a case insensitive regex of the value specified, e.g. { "publishedState": /^published$/i }
- Added: error handling to hooks. Currently only applies to errors encountered while executing a
beforeCreate
hook, an error is returned in the response:
{
"success": false,
"errors": [
{
"code": "API-0002",
"title": "Hook Error",
"details": "The hook 'myHook' failed: 'ReferenceError: title is not defined'",
"docLink": "http://docs.dadi.tech/api/errors/API-0002"
}
]
}
- Added: environment variables added for database configuration properties
Property | Environment variable |
---|---|
Database username | "DB_USERNAME" |
Database password | "DB_PASSWORD" |
Database name | "DB_NAME" |
Auth database username | "DB_AUTH_USERNAME" |
Auth database password | "DB_AUTH_PASSWORD" |
Auth database name | "DB_AUTH_NAME" |
- Changed: Modified the model instantiation to wait a second if the database hasn't been connected yet. This avoids the error about maximum event listeners being added in the
createIndex
method.
Version 1.13.1
Collection schema indexes
Version 1.13.1 introduces an extension to the index creation for collections. Indexes can be specified one of two ways. The existing config is still compatible:
"index": {
"enabled": true,
"keys": { "title": 1 }
}
The new config allows specifying more than one index for a collection, and giving a set of options to each one. This approach allows the creation of a unique index alongside a compound index, for example:
Note: the enabled
property is now ignored. If you have a configuration block for indexes, it is assumed you intend them to be enabled...
"index": [
{
"keys": {
"username": 1
},
"options": {
"unique": true
}
},
{
"keys": {
"platform": 1,
"platformUserId: 1
}
}
]
Collection schema validation
This version also adds validation to collection schemas so that if a sort field is specified but no index is specified for that field, an error is returned.
{
"code": "API-0001",
"title": "Missing Index Key",
"details": "'title' is specified as the primary sort field, but is missing from the index key collection."
}
Removal of log module
Client applications should use var log = require(‘@dadi/logger’)
inside custom endpoints instead.
Interactive tool for creating client records
This version changes the create-client
util to work as a small, interactive CLI tool, allowing users to choose the clientId/secret pair instead of using the default ones. It can be used when bootstrapping a DADI API application, or any time afterwards, to create a new client.
Usage
When using DADI API from source (e.g. cloning the repository):
node utils/create-client.js
When using DADI API as a NPM module:
npm explore @dadi/api -- npm run create-client
Example
==================================
DADI API Client Record Generator
==================================
-> Client identifier: (testClient) myClient
-> Secret access key: (secretSquirrel) mySecret
-> Access type (admin, user): (user) admin
(!) Is this ok?: (y/n) y
(*) Client created successfully:
{ clientId: 'myClient',
secret: 'mySecret',
type: 'admin',
_id: 57d4116c8aa4ab9d83bc6401 }
Version 1.12.0
-
fix: ensure composed array values match original order
-
feat: add name to endpoints #129
-
fix: values being overridden in partial document update #127
-
feat: add SSL support #119
-
fix: remove log rotation options #123
-
fix: modify nested query to compare strings
-
fix: get compose val from schema or model
-
fix: stringify objects within err obj
-
fix: reduce wait time on db ops, speeds up tests
-
fix: empty reference field results #118
-
fix: allow DateTime conversion to unix if value is in a different format. Introduces a field formatting param to compose according to type. Currently only
unix
with fallback toISO
.fieldName: { type: "DateTime", format: "unix", ... }
-
fix: allow Mixed fields with ids for legacy CMS
-
fix: remove options from count endpoint
Version 1.11.0
Changes
Batch delete of documents
Usage:
Method: DELETE
URL: http://api.example.com/1.0/fictional-magazine-brand/articles
Body:
{
"query": {
"title": {"$in": ["foo", "bar", "baz]}
}
}
Filter revision history and return specified fields
The includeHistory
param now respects the fields
param, so that documents in history only contain the fields specified.
Added: a historyFilters
URL parameter, to be used in conjunction with includeHistory
, which adds the option to have a filter specific to the documents in history, with the same syntax as the existing filter
.
This makes it possible to retrieve only the revisions where name is Jim
:
http://api.example.com/1.0/fictional-magazine-brand/users/57866216acc4818e048efd36?includeHistory=true&historyFilters={"name":"Jim"}
Or get revisions between two dates:
http://api.example.com/1.0/fictional-magazine-brand/users/57866216acc4818e048efd36?includeHistory=true&historyFilters={"lastModifiedAt":{"$gte":1468424733361,"$lte":1468424737447}}
Environment variables for sensitive data
@dark12222000
Configuration variables likely to contain sensitive data can now be set from environment variables, rather than committing this data to config files.
Available variables:
- NODE_ENV
- HOST
- PORT
- REDIS_ENABLED
- REDIS_HOST
- REDIS_PORT
- REDIS_PASSWORD
- KINESIS_STREAM
Version 1.7.0
Changes since v1.6.0
- Add support for layout maps (0df5496)
- Introduce validation to fields of String containing an array of strings
- Add support for advanced regex and DateTime queries (1f3972c)
- Drop auth token indexes at startup and recreat, to ensure any change to configured TTL values is picked up
and reflected in the token expiry database index - Add
/api/endpoints
route to return endpoint information
Version 1.5.0
Batch updates
Send a query and an update in the body of a PUT
request to update all documents matching the query.
PUT /1.0/library/notices HTTP/1.1
Host: api.example.com
content-type: application/json
Authorization: Bearer 171c8c12-6e9b-47a8-be29-0524070b0c65
{
query: { "_id": { "$in": [1234,5678,9012,3456] } },
update: { "status": "published" }
}
Parse JS comments in endpoint files
This feature enables documentation written into endpoint JS files to be displayed in autogenerated API documentation available when using package @dadi/apidoc
Collection schema validation properties
validationRule
and limit
properties have been deprecated. See the new validation formats in the API documentation:
validationRule
replacement: https://github.com/dadi/api/blob/docs/docs/validation.md#regular-expression-validationlimit
replacement: https://github.com/dadi/api/blob/docs/docs/validation.md#length-validation
Fixes
Fix #58: fallback to the directory cache if Redis client is unable to connect
Fix #54: don't convert nested query fields if they are querying a field of type Object
Fix #51: allow mixed fields to contain objects, don't validate nested properties
against the collection schema
Refactor #56: replace /api/status
endpoint with version from @dadi/status repo
Version 1.4.0
Support for Hooks
1.4.0 adds support for triggers/hooks which are fired beforeCreate
, afterCreate
, beforeUpdate
, afterUpdate
, beforeDelete
, afterDelete
of documents. Provided by @eduardoboucas, many thanks for the hard work on this! Full documentation to be made available soon.
Breaking change: Endpoint Authentication
The default setting is now 'must authenticate'. This means if you have custom endpoints
that are currently open and you want them to stay that way, add this block to the JS file:
module.exports.model = {
settings: {
authenticate: false
}
}
Connection module
Previously created connections for every loaded collection, resulting in a new connection pool
for each collection. New behaviour is to create one connection per database - if you aren't
using enableCollectionDatabases
then this means you'll only be making one connection
to the database.
Other
- Fix #39. Apply apiVersion filter to query only if it's configured using the
useVersionFilter
property (ed1c1d8) - Fix #38. Allow Mixed fields through to the data query, giving back the power to use dot notation in the query (49a0a07)
- Add timestamps to console log statements (018f4f2)
- Modify API host and port requirements.
null
for host will allow connections on
any IPv6 address (if available), otherwise any IPv4 address. If port is0
a random port will be assigned (3d5e0e0) - Add response to OPTIONS requests, thanks @eduardoboucas (969d808)
- Add authentication on a per-HTTP method basis, thanks @eduardoboucas (a00b72c)
- Use HTTP PUT for updates (also backwards-compatible with POST) (865e7f6)
- Add WWW-Authenticate header to when sending HTTP 401 responses (4708020)
- Add config settings for log file rotation (4e7e81d)
- Add logging level to limit log records (e282e62)