UNPKG

31.8 kBMarkdownView Raw
1# Change Log
2All notable changes to this project will be documented in this file.
3
4The format is based on [Keep a Changelog](http://keepachangelog.com/)
5and this project adheres to [Semantic Versioning](http://semver.org/).
6
7## [4.4.1] (2018-11-28)
8
9### Fixed
10
11- [#516](https://github.com/dadi/api/issues/516): make media field handle legacy values
12
13## [4.4.0] (2018-11-22)
14
15### Added
16
17- [#415](https://github.com/dadi/api/issues/415): add Media field
18- [#451](https://github.com/dadi/api/issues/451): add new validation module and operators
19- [#498](https://github.com/dadi/api/issues/498): allow bulk upload and deletion of media documents
20- [#507](https://github.com/dadi/api/pull/507): allow arbitrary metadata on media documents
21- [#508](https://github.com/dadi/api/pull/508): support application/json content type when updating media documents
22- [#514](https://github.com/dadi/api/pull/514): add mimeType validation operator and `_composed` property to media documents
23
24### Changed
25
26- [#510](https://github.com/dadi/api/pull/510): replace spaces with underscores in media document filenames
27
28### Fixed
29
30- [#509](https://github.com/dadi/api/pull/509): use correct response codes when creating and updating media documents
31
32## [4.3.0] (2018-09-27)
33
34### Changed
35
36- [#490](https://github.com/dadi/api/issues/490): add i18n field character to /api/languages endpoint
37- [#492](https://github.com/dadi/api/issues/492): add collection schemas and settings to /api/collections endpoint
38
39## [4.2.2] (2018-09-04)
40
41### Changed
42
43- [#487](https://github.com/dadi/api/pull/487): return Promise from disk storage handler, resolves crash on media GET requests
44
45## [4.2.1] (2018-08-28)
46
47### Changed
48
49- [#485](https://github.com/dadi/api/pull/485): add lang fields to field projection
50
51## [4.2.0] (2018-08-20)
52
53### Added
54
55- [#453](https://github.com/dadi/api/issues/453): add support for arbitrary data against client records
56- [#462](https://github.com/dadi/api/issues/462): introduce `/api/client` endpoints
57- [#482](https://github.com/dadi/api/issues/482): add support for feature queries
58
59### Changed
60
61- [#474](https://github.com/dadi/api/issues/474): require current client secret when setting a new one
62- [#476](https://github.com/dadi/api/issues/476): remove internal properties from POST and PUT payloads
63
64## [4.1.1] (2018-08-01)
65
66### Added
67
68- [#465](https://github.com/dadi/api/issues/465): make ACL models accessible via an export
69
70## [4.1.0] (2018-08-01)
71
72### Added
73
74Two new features in this version of API, see https://docs.dadi.cloud/api for full details:
75
76- Multi-language support
77- Document indexing and Search
78
79## [4.0.4] (2018-07-30)
80
81### Fixed
82
83- [#469](https://github.com/dadi/api/issues/469): fix issue where querying String fields with a `$ne` operator causes the request to hang
84
85## [4.0.3] (2018-07-27)
86
87### Fixed
88
89- [#466](https://github.com/dadi/api/issues/466): allow processing of multiple image upload requests
90
91## [4.0.2] (2018-07-26)
92
93### Fixed
94
95- [#463](https://github.com/dadi/api/issues/463): fix issue with API version numbers containing a dot (`.`) when using the MongoDB data connector
96
97## [4.0.1] (2018-07-18)
98
99### Fixed
100
101- [#457](https://github.com/dadi/api/issues/457): reinstate `slug` property in /api/collections endpoint
102- [#460](https://github.com/dadi/api/pull/460): use correct permissions and status code when a role is revoked from a client
103
104## [4.0.0] (2018-07-11)
105
106### Added
107
108- [#396](https://github.com/dadi/api/issues/396): add access control list (see https://docs.dadi.cloud/api/4.0#authorisation-and-permissions)
109- [#449](https://github.com/dadi/api/pull/449): remove `/config` endpoints
110
111### Changed
112
113- [#438](https://github.com/dadi/api/issues/438): make CORS enabled by default
114- [#447](https://github.com/dadi/api/pull/447): adds an additional content type check when determining if the current request should be parsed by the JSON parsing middleware
115
116### BREAKING CHANGES
117
118#### Access control list
119
120The main change from version 3 to 4 is the introduction of the [access control list](https://docs.dadi.cloud/api/4.0#authorisation-and-permissions). It's technically a breaking change, since any clients without `{"accessType": "admin"}` will lose access to everything by default. They need to be assigned permissions for the individual resources they should be able to access, either directly or via roles.
121
122If you don't want to use the new advanced permissions and instead keep your clients with unrestricted access to API resources, make sure to set `{"accessType": "admin"}` in their database records. API doesn't currently offer a way to change this property via the endpoints, so you'll need to manually make this change in the database.
123
124#### Removal of write mode on configuration endpoints
125
126Version 4 removes the ability for clients to create, modify and delete collections, custom endpoints or update the main API configuration. The *read* endpoints were kept – e.g. `GET /api/config` is valid, but `POST /api/config` is not.
127
128#### Other breaking changes
129
130- Requesting a document by ID (e.g. `/version/database/collection/doc123456`) now returns a 404 if the given ID does not correspond to a valid document, instead of returning a 200 with an empty result set. This behaviour is consistent with the `DELETE` and `PUT` verbs.
131
132## [3.2.1] (2018-06-13)
133
134### Changed
135
136* [#435](https://github.com/dadi/api/issues/435): Fix issue where filtering `Object` fields with nested queries would return a 400 error.
137
138## [3.2.0] (2018-06-08)
139
140See release notes at https://github.com/dadi/api/releases/tag/v3.2.0
141
142### Added
143
144* [#431](https://github.com/dadi/api/pull/431): allow DELETE requests to media collection endpoints; enable `s3.endpoint` in the configuration to allow using Digital Ocean Spaces as a storage handler.
145
146## [3.1.2] (2018-05-01)
147
148### Changed
149
150* [#417](https://github.com/dadi/api/pull/417): Fix issue where `Reference` fields pointing to the media collection were not fully resolved.
151
152## [3.1.1] (2018-04-13)
153
154### Changed
155
156* [#413](https://github.com/dadi/api/pull/413): Pass `req` object to hooks.
157
158## [3.1.0-rc1] (2018-04-06)
159
160### Added
161
162* [#157](https://github.com/dadi/api/issues/157): Documents in Reference fields are now resolved multiple times if `settings.strictCompose` is set to `true`
163* [#177](https://github.com/dadi/api/issues/177): Model API now supports Promises and named parameters. old syntax is retained for backward-compatibility.
164* [#329](https://github.com/dadi/api/issues/329): Fields in referenced documents can now be specified using dot-notation in the existing `fields` parameter.
165* [#336](https://github.com/dadi/api/issues/336): A Reference field can now reference documents from multiple collections.
166* [#406](https://github.com/dadi/api/pull/406): Introduced handshake function to ensure compatibility of versions between API core and data connectors.
167
168### Changed
169
170* [#196](https://github.com/dadi/api/issues/196) and [#323](https://github.com/dadi/api/issues/323): Added field modules to encapsulate field-specific logic.
171* [#300](https://github.com/dadi/api/issues/300): `_createdAt` and `_lastModifiedAt` internal fields are now appended to documents in the Model class.
172* [#371](https://github.com/dadi/api/issues/371) and [#384](https://github.com/dadi/api/issues/384): Make defaults paths relative to the parent app, not the module.
173* [#390](https://github.com/dadi/api/issues/390): Falsy values of Reference fields are now ignored, preserving the behavior of any other Reference fields in the document.
174* [#394](https://github.com/dadi/api/issues/394): New DateTime field module now stores values as Unix timestamps and allows queries to be performed using any date format.
175* [#405](https://github.com/dadi/api/pull/405): Lock down major version of `@dadi/logger`.
176
177## [3.0.0] (2017-12-05)
178
179See full release notes at https://github.com/dadi/api/releases/tag/v3.0.0
180
181### Added
182
183#### Data Connectors
184
185API Version 3.0 supports multiple data connectors. In previous versions API used MongoDB as a backend; this is now configurable. API Data Connectors are available as NPM packages. To add one to your API installation, run the associated NPM install command:
186
187`$ npm install @dadi/api-mongodb --save`
188
189Each data connector has it's own configuration requirements, but API must also be configured to use the data connectors you select. Modify your API configuration as follows:
190
191```json
192{
193 "datastore": "@dadi/api-mongodb", // the NPM package name for the data connector to use for the content layer
194 "auth": {
195 "tokenUrl": "/token",
196 "tokenTtl": 1800,
197 "clientCollection": "clientStore",
198 "tokenCollection": "tokenStore",
199 "datastore": "@dadi/api-mongodb", // the NPM package name for the data connector to use for the authentication layer
200 "database": "test"
201 }
202}
203```
204
205In addition, the data connector itself normally requires it's own configuration file. For example the MongoDB data connector requires a file using the following naming convention `mongodb.<environment>.json`. These configuration files should be placed the `config` directory of the API application.
206
207#### Connection Recovery
208
209API is now capable of recovering from database connection failures. When API is started with no available database service it will keep retrying until a successful connection can be made, then it runs the normal boot process.
210
211In addition, if the database connection is lost during normal operation of API, any requests made while the connection is offline will result in a HTTP 503 returned to the client.
212
213The maximum number of connection retries can be configured in the main configuration file by adding the following block:
214
215```json
216"databaseConnection": {
217 "maxRetries": 5 // default 10
218}
219```
220
221### Changed
222
223* New startup message displayed, with links to documentation
224* [#141](https://github.com/dadi/api/issues/141): the internal fields will be prefixed with a special character (`_` by default) which is configurable using the configuration property `internalFieldsPrefix`
225* [#180](https://github.com/dadi/api/issues/180): document properties with `null` values are not returned as part of the response
226* [#251](https://github.com/dadi/api/issues/251): added a new `/hello` endpoint which returns HTTP 200 and a "Welcome to API" message
227* [#263](https://github.com/dadi/api/issues/263): all delete hooks now receive a `deletedDocs` property
228* [#314](https://github.com/dadi/api/issues/314): when configuration option `feedback` is `true` we now send a response body when deleting documents
229* [#327](https://github.com/dadi/api/issues/327): API becomes capable of recovering from database connection failures
230* [#328](https://github.com/dadi/api/issues/328): remove schema validation on settings: 'callback', 'defaultFilters', 'fieldLimiters' and 'count'. Now only requires 'cache' and 'authenticate'
231* [#332](https://github.com/dadi/api/issues/332): allow POST to collection endpoints using `text/plain` content-type, which will be converted if it is valid JSON
232* Configuration file validation removed, suppressing warnings on application startup
233* POST/PUT/DELETE using non-existing document identifiers returns a 404:
234
235DELETE requests throws a 404 (instead of 204) when deleting a non-existing document by ID. This applies to requests where the document ID is passed in the URL, not when in the body (e.g. DELETE /v1/db/collection/DOC-ID vs DELETE /v1/db/collection).
236
237POST/PUT requests throw a 404 when updating a non-existing document by ID. This applies to requests where the document ID is passed in the URL, not when in the body (e.g. PUT /v1/db/collection/DOC-ID vs PUT /v1/db/collection).
238
239Closes [#345](https://github.com/dadi/api/issues/345).
240
241## [2.2.9] (2017-12-05)
242
243### Changed
244
245Fix previous release 2.2.8: [#363](https://github.com/dadi/api/issues/363): allow OPTIONS method when calling the token route
246
247## [2.2.8] (2017-12-04)
248
249### Changed
250
251[#363](https://github.com/dadi/api/issues/363): allow OPTIONS method when calling the token route
252
253## [2.2.0] (2017-07-05)
254
255### Changed
256
257[#289](https://github.com/dadi/api/issues/289): improved error response from hooks, with custom error support
258[#311](https://github.com/dadi/api/issues/311): fix a bug that caused multiple newly-created reference field subdocuments to be returned as a poorly-formed array
259
260## [2.1.2] (2017-06-29)
261
262### Changed
263
264[#289](https://github.com/dadi/api/issues/289): improved error response from hooks
265[#305](https://github.com/dadi/api/issues/305): remove restriction on environment settings. Use any environment name and configuration file, rather than only "development", "qa", "production", "test"
266[#306](https://github.com/dadi/api/issues/306): fix reference field composition when value is an empty array
267
268## [2.1.0] (2017-05-29)
269
270### Added
271
272* [#298](https://github.com/dadi/api/issues/298): documents to be deleted will first have the current state written into the history collection, if enabled
273
274### Changed
275
276* add additional property `action` to history revision documents. Possible values are "update", "delete" and the appropriate value is selected when updating/deleting records
277* add additional property `originalDocumentId` to history revision documents, value is the identifier of the parent document.
278
279## [2.0.0] (2017-05-29)
280
281### Changed
282
283#### Upgraded MongoDB driver
284Upgrade MongoDB driver to 2.2.x, from the existing 1.4.x version.
285
286#### Fixed `create-client` script
287 * use correct `accessType` property in client store documents
288 * abort if chosen clientId exists already
289
290#### Generate new documents from a pre-composed document
291
292It is now possible to send API a full document containing pre-composed Reference fields. API will translate such a request into individual documents for the relevant collections. This functionality reduces the number of API calls that must be made from an application when inserting data.
293
294##### For example
295
296Assume we have two collections, `people` and `cars`. `cars` is a Reference field within the `people` collection schema. Given the following body in a POST request to `/1.0/car-club/people`:
297
298```json
299{
300 "name": "Joe",
301 "cars": [
302 {
303 "model": "Lamborghini Diablo",
304 "year": 1991
305 }
306 ]
307}
308```
309
310API will automatically create new documents in the `cars` collection and use the new identifier value in the `people` document. The final `people` document would look similar to this:
311
312```json
313{
314 "name": "Joe",
315 "cars": [
316 "587cb6aa80222c9e7266cec0"
317 ]
318}
319```
320
321
322#### Media collections
323This version introduces a few changes to how media is handled by API.
324
325The concept of media collections has been abstracted from the public API. It removes the requirement for a collection schema, instead using a schema kept internally in API. At the moment it's hardcoded to store images (containing dimensions, size, mime type, etc.), but in the future we will look into making the schema adapt to the type of file being uploaded.
326
327##### Endpoints
328
329| Method | Endpoint | Purpose | Example
330|:-|:---|:----|:--
331| POST |`/media/sign`| Requesting a signed URL for a media upload| |
332| POST |`/media/:signedUrl`|Uploading a media asset ||
333| GET | `/media`|Listing media assets ||
334| GET | `/media/:assetPath`|Access a specific media asset | `/media/2017/04/27/flowers.jpg`
335
336#### Media buckets
337
338Even though that's abstracted from the end user, assets still need to be stored in collections. Assets POSTed to /media will be stored in a `mediaStore` collection (configurable via the `media.defaultBucket` configuration parameter). It is also possible to add additional "media buckets", configured as an array in the `media.buckets` configuration parameter.
339
340##### Endpoints
341
342Here are the same media collection endpoints for interacting with a media bucket called `mediaAvatars`:
343
344| Method | Endpoint | Purpose | Example
345|:-|:---|:----|:--
346| POST |`/media/mediaAvatars/sign`| Requesting a signed URL for a media upload| |
347| POST |`/media/mediaAvatars/:signedUrl`|Uploading a media asset ||
348| GET | `/media/mediaAvatars`|Listing media assets ||
349| GET | `/media/mediaAvatars/:assetPath`|Access a specific media asset | `/media/mediaAvatars/2017/04/27/flowers.jpg`
350
351#### Naming conflicts
352
353If there is a data collection with the same name as one of the media buckets, API throws an error detailing the name of the conflicting collection.
354
355#### Discovering media buckets
356
357Added information about media buckets to the /api/collections endpoint, indicating a list of the available media buckets as well as the name of the default one.
358
359```
360GET /api/collections
361```
362
363```json
364{
365 "collections": [
366 {
367 "version": "1.0",
368 "database": "library",
369 "name": "Articles",
370 "slug": "articles",
371 "path": "/1.0/library/articles"
372 },
373 {
374 "version": "1.0",
375 "database": "library",
376 "name": "Books",
377 "slug": "books",
378 "path": "/1.0/library/books"
379 }
380 ],
381 "media": {
382 "buckets": [
383 "authorImages",
384 "mediaStore"
385 ],
386 "defaultBucket": "mediaStore"
387 }
388}
389```
390
391#### Add `url` property to media documents
392Instead of replacing the contents of `path`, leave that as it is and write the full URL to a new property called `url`.
393
394```json
395"image": {
396 "_id": "591b5f29795b683664af01e9",
397 "fileName": "3RdYMTLoL1X16djGF52cFtJovDT.jpg",
398 "mimetype": "image/jpeg",
399 "width": 600,
400 "height": 900,
401 "contentLength": 54907,
402 "path": "/media/2017/05/16/3RdYMTLoL1X16djGF52cFtJovDT-1494966057926.jpg",
403 "createdAt": 1494966057685,
404 "createdBy": null,
405 "v": 1,
406 "url": "http://localhost:5000/media/2017/05/16/3RdYMTLoL1X16djGF52cFtJovDT-1494966057926.jpg"
407}
408```
409
410#### Hook configuration endpoints
411
412Extended the hooks config endpoint (`/api/hooks/:hookName/config`) to accept POST, PUT and DELETE requests to create, update and delete hooks, respectively.
413
414#### Other
415
416* [#245](https://github.com/dadi/api/issues/245): fix media path formatting
417* [#246](https://github.com/dadi/api/issues/246): ignore _id field in query when processing query filters
418* [#257](https://github.com/dadi/api/issues/257): improve performance of Reference field composition
419* [#265](https://github.com/dadi/api/issues/265): validate arrays against schemas in POST requests
420* [#284](https://github.com/dadi/api/issues/284): check indexes correctly when given a sort key
421* remove `apiVersion` query property when composing reference fields, improves performance
422
423### Added
424
425#### MongoDB readPreference configuration
426Added `readPreference` configuration option. Default is `secondaryPreferred`. Closed [#156](https://github.com/dadi/api/issues/156)
427
428```json
429"database": {
430 "hosts": [
431 {
432 "host": "127.0.0.1",
433 "port": 27017
434 }
435 ],
436 "username": "",
437 "password": "",
438 "database": "api",
439 "ssl": false,
440 "replicaSet": "",
441 "enableCollectionDatabases": false,
442 "readPreference": "primary"
443}
444```
445
446#### API baseUrl
447
448We've introduced a `server.baseUrl` configuration parameter, which will be used to determine the URL of media assets when using the disk storage option.
449
450```json
451"baseUrl": {
452 "protocol": "http",
453 "port": 80,
454 "host": "mydomain.com"
455}
456```
457
458
459#### Post install script
460
461Added a post install script which runs following an install of API from NPM. A development configuration file is created along with a basic workspace directory containing two collections, an endpoint and a hook. No files are overwritten if the config and workspace directories already exist.
462
463## [1.16.6] (2017-05-25)
464
465### Changed
466* improved check within composer module that ignores "undefined" values as well as "null"
467
468## [1.16.5] (2017-05-12)
469
470### Changed
471* [#260](https://github.com/dadi/api/issues/260): change media collection type to "mediaCollection"
472
473## [1.16.4] (2017-05-12)
474
475### Changed
476* [#211](https://github.com/dadi/api/issues/211): fix composition so it doesn't return before all fields have been composed
477
478## [1.15.5] (2017-03-30)
479
480### Changed
481* [#226](https://github.com/dadi/api/issues/226): historyFilters corrupt model filters
482
483## [1.15.4] (2017-02-15)
484
485### Changed
486* pass auth indicator to connection ([1d3ebed](https://github.com/dadi/api/commit/1d3ebed))
487
488
489## [1.15.3] (2017-02-15)
490
491### Changed
492
493* [#200](https://github.com/dadi/api/issues/200): explicitly add "node" command to create-client script ([8394355](https://github.com/dadi/api/commit/8394355))
494
495
496## [1.15.2] (2017-01-31)
497
498### Changed
499
500* select non-null fields for composition ([21e48bf](https://github.com/dadi/api/commit/21e48bf))
501
502## [1.15.1] (2017-01-23)
503
504### Changed
505
506* revert mongodb version to allow full 1.4 range ([0d2398c](https://github.com/dadi/api/commit/0d2398c))
507
508## [1.15.0] (2017-01-18)
509
510### Added
511
512* add busboy dependency ([3eda9fe](https://github.com/dadi/api/commit/3eda9fe))
513* add configurable media collection name ([c038a58](https://github.com/dadi/api/commit/c038a58))
514* add error handling to remaining hook types ([79df695](https://github.com/dadi/api/commit/79df695))
515* add redirectPort to config ([e1d6c58](https://github.com/dadi/api/commit/e1d6c58))
516* add Redis cache tests back after a long time in exile ([5f3618e](https://github.com/dadi/api/commit/5f3618e))
517* improve SSL handling ([80073eb](https://github.com/dadi/api/commit/80073eb))
518* move media upload to new controller ([12cd39c](https://github.com/dadi/api/commit/12cd39c))
519
520### Changed
521
522* [#164](https://github.com/dadi/api/issues/164): use platform agnostic approach to directory separators ([d4e49b2](https://github.com/dadi/api/commit/d4e49b2))
523* add current year to copyright notice ([1e5be89](https://github.com/dadi/api/commit/1e5be89))
524* missing dependencies ([3a4dd51](https://github.com/dadi/api/commit/3a4dd51))
525* remove unnecessary escape chars ([73aad00](https://github.com/dadi/api/commit/73aad00))
526* remove unused variable ([4b741e3](https://github.com/dadi/api/commit/4b741e3))
527* resolve ObjectIDs in batch delete query ([3d407f9](https://github.com/dadi/api/commit/3d407f9))
528* send error response if path not specified ([c14edf2](https://github.com/dadi/api/commit/c14edf2))
529* use platform agnostic path separator ([cfec695](https://github.com/dadi/api/commit/cfec695))
530
531
532## [1.14.1] (2016-12-28)
533### Changed
534* [#164](https://github.com/dadi/api/issues/164): Modified collection and endpoint loading to use the current platform's directory separator, rather than assuming '/', which fails under Windows.
535
536
537## [1.14.0] (2016-11-10)
538### Added
539* Added a `matchType` property to fields in collection schemas. Determines the type of match allowed when querying using this field. Possible values:
540
541|Value | Behaviour
542|:---|:-----
543| "exact" | query will be performed using the exact value specified, e.g. { "publishedState": "published" }
544| "ignoreCase" | query will be performed using a case insensitive regex of the value specified, e.g. { "publishedState": /^published$/i }
545| "anything else" | query will be performed using a regex of the value specified, e.g. { "publishedState": /^published$/ }
546
547> **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 }
548
549* Added error handling to beforeCreate hooks. If an error is encountered while executing a beforeCreate hook, an error is returned in the response:
550
551```json
552{
553 "success": false,
554 "errors": [
555 {
556 "code": "API-0002",
557 "title": "Hook Error",
558 "details": "The hook 'myHook' failed: 'ReferenceError: title is not defined'",
559 "docLink": "http://docs.dadi.tech/api/errors/API-0002"
560 }
561 ]
562}
563```
564
565* Added environment variables for database configuration properties:
566
567|Property | Environment variable
568|:---|:-----
569|Database username| "DB_USERNAME"
570|Database password| "DB_PASSWORD"
571|Database name| "DB_NAME"
572|Auth database username| "DB_AUTH_USERNAME"
573|Auth database password| "DB_AUTH_PASSWORD"
574|Auth database name| "DB_AUTH_NAME"
575
576### Changed
577
578* 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.
579
580## [1.11.1] (2016-07-16)
581
582* no longer convert to ObjectID if the query is using dot notation and the parent field
583is of type `Mixed`. This supports legacy CMS use in some cases
584* remove the options when calling a collection's count endpoint, to ensure no
585`limit` parameter is sent
586
587## [1.11.0] (2016-07-14)
588
589### Batch delete of documents
590@eduardoboucas
591
592**Usage:**
593
594Method: DELETE
595URL: `http://api.example.com/1.0/fictional-magazine-brand/articles`
596
597Body:
598```
599{
600 "query": {
601 "title": {"$in": ["foo", "bar", "baz]}
602 }
603}
604```
605
606### Filter revision history and return specified fields
607@eduardoboucas
608
609The `includeHistory` param now respects the `fields` param, so that documents in history only contain the fields specified.
610
611Added: 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`.
612
613This makes it possible to retrieve only the revisions where name is `Jim`:
614
615```
616http://api.example.com/1.0/fictional-magazine-brand/users/57866216acc4818e048efd36?includeHistory=true&historyFilters={"name":"Jim"}
617```
618
619Or get revisions between two dates:
620
621```
622http://api.example.com/1.0/fictional-magazine-brand/users/57866216acc4818e048efd36?includeHistory=true&historyFilters={"lastModifiedAt":{"$gte":1468424733361,"$lte":1468424737447}}
623```
624
625### Environment variables for sensitive data
626@dark12222000
627
628Configuration variables likely to contain sensitive data can now be set from environment variables, rather than committing this data to config files.
629
630Available variables:
631
632* NODE_ENV
633* HOST
634* PORT
635* REDIS_ENABLED
636* REDIS_HOST
637* REDIS_PORT
638* REDIS_PASSWORD
639* KINESIS_STREAM
640
641
642## [1.4.0] (2016-03-24)
643
644### Support for Hooks (beforeCreate, afterCreate, beforeUpdate, afterUpdate, beforeDelete, afterDelete).
645Provided by @eduardoboucas, many thanks for the hard work on this! Full documentation to be made available soon.
646
647### Breaking change: Endpoint Authentication
648
649The default setting is now 'must authenticate'. This means if you have custom endpoints
650that are currently open and you want them to stay that way, add this block to the JS file:
651
652```
653module.exports.model = {
654 settings: {
655 authenticate: false
656 }
657}
658```
659
660### Connection module
661
662Previously created connections for every loaded collection, resulting in a new connection pool
663for each collection. New behaviour is to create one connection per database - if you aren't
664using `enableCollectionDatabases` then this means you'll only be making one connection
665to the database.
666
667### Other
668* Fix #39. Apply apiVersion filter to query only if it's configured using the `useVersionFilter` property (ed1c1d8)
669* Fix #38. Allow Mixed fields through to the data query, giving back the power to use dot notation in the query (49a0a07)
670* Add timestamps to console log statements (018f4f2)
671* Modify API host and port requirements. `null` for host will allow connections on
672 any IPv6 address (if available), otherwise any IPv4 address. If port is `0` a random port will be assigned (3d5e0e0)
673* Add response to OPTIONS requests, thanks @eduardoboucas (969d808)
674* Add authentication on a per-HTTP method basis, thanks @eduardoboucas (a00b72c)
675* Use HTTP PUT for updates (also backwards-compatible with POST) (865e7f6)
676* Add WWW-Authenticate header to when sending HTTP 401 responses (4708020)
677* Add config settings for log file rotation (4e7e81d)
678* Add logging level to limit log records (e282e62)
679
680## [1.3.0] (2016-02-26)
681
682Fix #13: Removed auto-creation of API docs path (should only happen if api-doc module is installed)
683Close #14: Load domain-specific configuration if matching file exists
684Close #16: Check that generated auth token doesn't already exist, generate new one if it does
685Close #18: Validate `skip` & `page` parameters before calling `model.find()`
686Close #19: Database `replicaSet` property should be a String, not a Boolean
687Cache: add Redis caching ability and extend config to allow switching between filesystem and Redis caches
688Cache: locate endpoint matching the request URL using path-to-regex so we can be certain of a match
689---
690## [1.2.2] (2016-01-18)
691* Requests for paths containing `docs` skip authentication
692* Custom endpoints with JS comments in the head of the file will have those comments added to the global app object, making for more meaningful API documentation (with the use of npm package `dadi-apidoc`)
693
694## [1.2.1] (2016-01-13)
695
696* `Model.find()`
697 * convert simple string filters to ObjectID if they appear to be valid ObjectIDs
698
699## [1.2.0] (2016-01-06)
700
701* `Model.find()`
702 * collection setting `defaultFilters` now used when performing a GET request, in addition to filters passed in the querystring
703 * collection setting `fieldLimiters` now used when performing a GET request, in addition to fields passed in the querystring
704 * `skip` can be passed in the querystring to explicitly set an offset. The `skip` value is normally calculated using the `count` and `page` values, so if `count = 10` and `page = 2` then `skip` becomes `10` (i.e. `(page-1)*count`). If `skip` is specified in the querystring, this value is added to the calculated value to avoid overlapping records on subsequent pages.
705
706* Validation: the `limit` and `validationRule` schema properties have been deprecated in favour of the below. Not all rules are required, of course:
707
708 ```
709 validation: {
710 minLength: 1,
711 maxLength: 20,
712 regex: {
713 pattern: /^abc/
714 }
715 }
716 ```
717
718## v0.1.10 (2015-11-18)
719
720### Database
721
722* MongoDB Replica Set support
723* `create()` and `update()` operations return a `results` object the same as `find()`
724* Startup process now checks for existence of an index on the configured `tokenStore` collection: `{ 'token': 1,'tokenExpire': 1 }`
725* TTL index on the `tokenStore` collection is set to remove documents immediately after the `tokenExpire` value
726* Pass the API version from the querystring to the `find()` query
727* Collection-level databases are now fully enabled. A collection as `/1.0/reviews/articles` will use a `reviews` database. This mode is disabled by default and can be enabled within the database configuration section via the "enableCollectionDatabases" property:
728
729```
730 "database": {
731 "hosts": [
732 {
733 "host": "127.0.0.1",
734 "port": 27017
735 }
736 ],
737 "username": "",
738 "password": "",
739 "database": "serama",
740 "ssl": false,
741 "replicaSet": false,
742 "enableCollectionDatabases": true
743 }
744```
745
746
747### Collection Schema & Validation
748
749* Schema validation has been relaxed for update operations. Serama previously expected all required fields to be supplied in an update request, now it's fine to send only changed data
750* Fix to allow required Boolean fields to be set to false
751
752* removed references to /endpoints
753
754### Authentication & Authorisation
755
756* Add `created` field when creating new auth tokens to enable automatic removal by TTL index
757* Fixed support for client authorisation by API version, in case you need to restrict a set of users to a specific version of the API:
758
759```
760{
761 clientId: 'clientX',
762 secret: 'secret',
763 accessType: 'user',
764 permissions: {
765 collections: [ { apiVersion: "1.0", path: "test-collection" } ],
766 endpoints: [ { apiVersion: "1.0", path: "test-endpoint" } ]
767 }
768}
769```
770
771### Cache
772* Flush model cache on DELETE requests
773* added X-Cache and X-Cache-Lookup headers
774* added Server name header, default is `Bantam (Serama)`
775
776### Compose - Reference Fields
777* allow enabling compose by querystring
778* remove query parameters that don't exist in the model schema
779
780### Tests
781* check for existence of `test` database before continuing
782* use `test` database or `testdb` explicitly in some tests
783
\No newline at end of file