Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit ac9fcd4

Browse files
authoredAug 1, 2018
Merge pull request share#228 from Teamwork/warn-about-deprecated-features
Warn about using deprecated features
2 parents 721a0ab + 39a95c8 commit ac9fcd4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎README.md

-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ Register a new middleware.
139139
One of:
140140
* `'connect'`: A new client connected to the server.
141141
* `'op'`: An operation was loaded from the database.
142-
* `'doc'`: DEPRECATED: A snapshot was loaded from the database. Please use 'readSnapshots'
143142
* `'readSnapshots'`: Snapshot(s) were loaded from the database for a fetch or subscribe of a query or document
144143
* `'query'`: A query is about to be sent to the database
145144
* `'submit'`: An operation is about to be submitted to the database

‎lib/backend.js

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ var projections = require('./projections');
99
var QueryEmitter = require('./query-emitter');
1010
var StreamSocket = require('./stream-socket');
1111
var SubmitRequest = require('./submit-request');
12+
var warnDeprecatedDoc = true;
13+
var warnDeprecatedAfterSubmit = true;
1214

1315
function Backend(options) {
1416
if (!(this instanceof Backend)) return new Backend(options);
@@ -71,6 +73,11 @@ Backend.prototype.MIDDLEWARE_ACTIONS = {
7173
};
7274

7375
Backend.prototype._shimDocAction = function() {
76+
if (warnDeprecatedDoc) {
77+
warnDeprecatedDoc = false;
78+
console.warn('DEPRECATED: "doc" middleware action. Use "readSnapshots" instead. Pass `disableDocAction: true` option to ShareDB to disable the "doc" action and this warning.');
79+
}
80+
7481
var backend = this;
7582
this.use(this.MIDDLEWARE_ACTIONS.readSnapshots, function(request, callback) {
7683
async.each(request.snapshots, function(snapshot, eachCb) {
@@ -83,6 +90,11 @@ Backend.prototype._shimDocAction = function() {
8390
// Shim for backwards compatibility with deprecated middleware action name.
8491
// The action 'after submit' is now 'afterSubmit'.
8592
Backend.prototype._shimAfterSubmit = function() {
93+
if (warnDeprecatedAfterSubmit) {
94+
warnDeprecatedAfterSubmit = false;
95+
console.warn('DEPRECATED: "after submit" middleware action. Use "afterSubmit" instead. Pass `disableSpaceDelimitedActions: true` option to ShareDB to disable the "after submit" action and this warning.');
96+
}
97+
8698
var backend = this;
8799
this.use(backend.MIDDLEWARE_ACTIONS.afterSubmit, function(request, callback) {
88100
backend.trigger(backend.MIDDLEWARE_ACTIONS['after submit'], request.agent, request, callback);

0 commit comments

Comments
 (0)
This repository has been archived.