YishTish 9d96ab0983
Nodejs express js packages update (#5675)
* Updated to new nodejs packages, depending heavily on express-openapi-validator. Requires quite a change in code.
Updated the business-logic in the controllers/Controller.js file.
Logger now records also timestamp of events.
Files are uploaded according to definition in config.js file

* Removed commented-out code; Changed openApi document extensions to suit new express-openapi-validator definition; multipart and file uploading is supported now; Automatic response returns the values the were sent in the request

* fixed README documentation, fixed a mistage in package.json/mustache

* added generated files that were created when running the ./bin/test file
2020-03-24 17:37:18 +08:00

92 lines
2.0 KiB
JavaScript

/* eslint-disable no-unused-vars */
const Service = require('./Service');
/**
* Delete purchase order by ID
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
*
* orderId String ID of the order that needs to be deleted
* no response value expected for this operation
* */
const deleteOrder = ({ orderId }) => new Promise(
async (resolve, reject) => {
try {
resolve(Service.successResponse({
orderId,
}));
} catch (e) {
reject(Service.rejectResponse(
e.message || 'Invalid input',
e.status || 405,
));
}
},
);
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
*
* returns Map
* */
const getInventory = () => new Promise(
async (resolve, reject) => {
try {
resolve(Service.successResponse({
}));
} catch (e) {
reject(Service.rejectResponse(
e.message || 'Invalid input',
e.status || 405,
));
}
},
);
/**
* Find purchase order by ID
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
*
* orderId Long ID of pet that needs to be fetched
* returns Order
* */
const getOrderById = ({ orderId }) => new Promise(
async (resolve, reject) => {
try {
resolve(Service.successResponse({
orderId,
}));
} catch (e) {
reject(Service.rejectResponse(
e.message || 'Invalid input',
e.status || 405,
));
}
},
);
/**
* Place an order for a pet
*
* body Order order placed for purchasing the pet
* returns Order
* */
const placeOrder = ({ body }) => new Promise(
async (resolve, reject) => {
try {
resolve(Service.successResponse({
body,
}));
} catch (e) {
reject(Service.rejectResponse(
e.message || 'Invalid input',
e.status || 405,
));
}
},
);
module.exports = {
deleteOrder,
getInventory,
getOrderById,
placeOrder,
};