forked from loafle/openapi-generator-original
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:
@@ -1,42 +1,53 @@
|
||||
/**
|
||||
* The UserController 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/UserService');
|
||||
const createUser = async (request, response) => {
|
||||
await Controller.handleRequest(request, response, service.createUser);
|
||||
};
|
||||
|
||||
class UserController {
|
||||
constructor(Service) {
|
||||
this.service = Service;
|
||||
}
|
||||
const createUsersWithArrayInput = async (request, response) => {
|
||||
await Controller.handleRequest(request, response, service.createUsersWithArrayInput);
|
||||
};
|
||||
|
||||
async createUser(request, response) {
|
||||
await Controller.handleRequest(request, response, this.service.createUser);
|
||||
}
|
||||
const createUsersWithListInput = async (request, response) => {
|
||||
await Controller.handleRequest(request, response, service.createUsersWithListInput);
|
||||
};
|
||||
|
||||
async createUsersWithArrayInput(request, response) {
|
||||
await Controller.handleRequest(request, response, this.service.createUsersWithArrayInput);
|
||||
}
|
||||
const deleteUser = async (request, response) => {
|
||||
await Controller.handleRequest(request, response, service.deleteUser);
|
||||
};
|
||||
|
||||
async createUsersWithListInput(request, response) {
|
||||
await Controller.handleRequest(request, response, this.service.createUsersWithListInput);
|
||||
}
|
||||
const getUserByName = async (request, response) => {
|
||||
await Controller.handleRequest(request, response, service.getUserByName);
|
||||
};
|
||||
|
||||
async deleteUser(request, response) {
|
||||
await Controller.handleRequest(request, response, this.service.deleteUser);
|
||||
}
|
||||
const loginUser = async (request, response) => {
|
||||
await Controller.handleRequest(request, response, service.loginUser);
|
||||
};
|
||||
|
||||
async getUserByName(request, response) {
|
||||
await Controller.handleRequest(request, response, this.service.getUserByName);
|
||||
}
|
||||
const logoutUser = async (request, response) => {
|
||||
await Controller.handleRequest(request, response, service.logoutUser);
|
||||
};
|
||||
|
||||
async loginUser(request, response) {
|
||||
await Controller.handleRequest(request, response, this.service.loginUser);
|
||||
}
|
||||
const updateUser = async (request, response) => {
|
||||
await Controller.handleRequest(request, response, service.updateUser);
|
||||
};
|
||||
|
||||
async logoutUser(request, response) {
|
||||
await Controller.handleRequest(request, response, this.service.logoutUser);
|
||||
}
|
||||
|
||||
async updateUser(request, response) {
|
||||
await Controller.handleRequest(request, response, this.service.updateUser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = UserController;
|
||||
module.exports = {
|
||||
createUser,
|
||||
createUsersWithArrayInput,
|
||||
createUsersWithListInput,
|
||||
deleteUser,
|
||||
getUserByName,
|
||||
loginUser,
|
||||
logoutUser,
|
||||
updateUser,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user