2018-10-09 20:30:59 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2019-01-24 23:51:05 +08:00
|
|
|
/**
|
|
|
|
* @template DeserializedType
|
|
|
|
* @template SerializedType
|
|
|
|
*/
|
2018-10-09 20:30:59 +08:00
|
|
|
class SerializerMiddleware {
|
|
|
|
/**
|
2019-01-24 23:51:05 +08:00
|
|
|
* @param {DeserializedType} data data
|
|
|
|
* @param {Object} context context object
|
|
|
|
* @returns {SerializedType|Promise<SerializedType>} serialized data
|
2018-10-09 20:30:59 +08:00
|
|
|
*/
|
|
|
|
serialize(data, context) {
|
|
|
|
throw new Error(
|
|
|
|
"Serializer.serialize is abstract and need to be overwritten"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-01-24 23:51:05 +08:00
|
|
|
* @param {SerializedType} data data
|
|
|
|
* @param {Object} context context object
|
|
|
|
* @returns {DeserializedType|Promise<DeserializedType>} deserialized data
|
2018-10-09 20:30:59 +08:00
|
|
|
*/
|
|
|
|
deserialize(data, context) {
|
|
|
|
throw new Error(
|
|
|
|
"Serializer.deserialize is abstract and need to be overwritten"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = SerializerMiddleware;
|