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
This commit is contained in:
YishTish
2020-03-24 11:37:18 +02:00
committed by GitHub
parent eac18a779d
commit 9d96ab0983
27 changed files with 1080 additions and 1688 deletions

View File

@@ -1,42 +1,53 @@
/**
* The PetController file is a very simple one, which does not need to be changed manually,
* unless there's a case where business logic reoutes the request to an entity which is not
* the service.
* The heavy lifting of the Controller item is done in Request.js - that is where request
* parameters are extracted and sent to the service, and where response is handled.
*/
const Controller = require('./Controller');
const service = require('../services/PetService');
const addPet = async (request, response) => {
await Controller.handleRequest(request, response, service.addPet);
};
class PetController {
constructor(Service) {
this.service = Service;
}
const deletePet = async (request, response) => {
await Controller.handleRequest(request, response, service.deletePet);
};
async addPet(request, response) {
await Controller.handleRequest(request, response, this.service.addPet);
}
const findPetsByStatus = async (request, response) => {
await Controller.handleRequest(request, response, service.findPetsByStatus);
};
async deletePet(request, response) {
await Controller.handleRequest(request, response, this.service.deletePet);
}
const findPetsByTags = async (request, response) => {
await Controller.handleRequest(request, response, service.findPetsByTags);
};
async findPetsByStatus(request, response) {
await Controller.handleRequest(request, response, this.service.findPetsByStatus);
}
const getPetById = async (request, response) => {
await Controller.handleRequest(request, response, service.getPetById);
};
async findPetsByTags(request, response) {
await Controller.handleRequest(request, response, this.service.findPetsByTags);
}
const updatePet = async (request, response) => {
await Controller.handleRequest(request, response, service.updatePet);
};
async getPetById(request, response) {
await Controller.handleRequest(request, response, this.service.getPetById);
}
const updatePetWithForm = async (request, response) => {
await Controller.handleRequest(request, response, service.updatePetWithForm);
};
async updatePet(request, response) {
await Controller.handleRequest(request, response, this.service.updatePet);
}
const uploadFile = async (request, response) => {
await Controller.handleRequest(request, response, service.uploadFile);
};
async updatePetWithForm(request, response) {
await Controller.handleRequest(request, response, this.service.updatePetWithForm);
}
async uploadFile(request, response) {
await Controller.handleRequest(request, response, this.service.uploadFile);
}
}
module.exports = PetController;
module.exports = {
addPet,
deletePet,
findPetsByStatus,
findPetsByTags,
getPetById,
updatePet,
updatePetWithForm,
uploadFile,
};