UNPKG

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