imp(middlware-joi): package deprecation
MODIFY
packages/middleware-joi/package.json
packages/middleware-joi/package.json
"build": "tsc",
"lint": "tslint --config ../../tslint.json --project ./",
"test": "jest --config ../../jest.config.js",
- "clean": "rimraf dist"
+ "clean": "rimraf dist",
+ "postinstall": "node ./src/deprecation.js"
},
"files": [
"dist/"

ADD
packages/middleware-joi/src/deprecation.js
+console.warn(`
+ Deprecation warning: @marblejs/middleware-joi is deprecated since v2.0.
+ Use @marblejs/middlware-io instead.
+`);

MODIFY
packages/middleware-joi/src/validator.middleware.ts
packages/middleware-joi/src/validator.middleware.ts
@@ -23,9 +23,16 @@ const validateSource = (rules: Map<string, any>, options: Joi.ValidationOptions)
mapTo(req)
);
+/**
+ * @deprecated [#1] since version 2.0,
+ * [#2] use @marblejs/middlware-io instead,
+ */
export const validator$ = <TBody = any, TParams = any, TQuery = any>
(schema: Partial<Schema<TBody, TParams, TQuery>>, options: Joi.ValidationOptions = {}) =>
(req$: Observable<HttpRequest>) => {
+ // tslint:disable-next-line:max-line-length
+ console.warn('Deprecation warning: @marblejs/middleware-joi is deprecated since v2.0. Use @marblejs/middlware-io instead.');
+
const result = Joi.validate(schema, SchemaValidator);
const rules = Object.keys(schema).reduce(
(acc, value) => acc.set(value, Joi.compile(schema[value])),

MODIFY
packages/middleware-joi/test/integration/integration.spec.ts
packages/middleware-joi/test/integration/integration.spec.ts
@@ -5,6 +5,10 @@ describe('Joi middleware - Integration', () => {
const app = server();
const token = '181782881DB38D84';
+ beforeEach(() => {
+ jest.spyOn(console, 'warn').mockImplementation(jest.fn);
+ });
+
it('should fail without a token', async () => {
const expected = {
error: {

imp(middlware-joi): package deprecation (#99)