-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the create accomodation facility by the travel Admin
- Loading branch information
1 parent
fe16abe
commit 0c0d94b
Showing
7 changed files
with
72 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import models from '../models'; | ||
import { HelperMethods } from '../utils'; | ||
|
||
// const { Accommodation } = models; | ||
|
||
/** | ||
* Class representing the Accomodation controller | ||
* @class AccomodationController | ||
* @description accomodation controller | ||
*/ | ||
class AccomodationController { | ||
/** | ||
* Create a Accomodation Facilty | ||
* Route: POST: /accomodation | ||
* @param {object} req - HTTP Request object | ||
* @param {object} res - HTTP Response object | ||
* @return {res} res - HTTP Response object | ||
* @memberof AccomodationController | ||
*/ | ||
static async createAccomodation(req, res) { | ||
try { | ||
const { dataValues } = await models.Accommodation.create({ ...req.body }); | ||
console.log(dataValues); | ||
|
||
if (dataValues.id) { | ||
HelperMethods.requestSuccessful(res, { | ||
success: true, | ||
message: 'Accomodation created successfully', | ||
data: dataValues, | ||
}, 201); | ||
} | ||
} catch (error) { | ||
// HelperMethods.serverError(res, 'Something failed'); | ||
// console.log(error.message); | ||
throw error; | ||
} | ||
} | ||
} | ||
|
||
export default AccomodationController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import UserController from './UserController'; | ||
import RequestController from './RequestController'; | ||
import AccomodationController from './AccomodationController'; | ||
|
||
export { UserController, RequestController }; | ||
export { UserController, RequestController, AccomodationController }; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,4 @@ export default (sequelize, DataTypes) => { | |
|
||
return Accommodation; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AccomodationController } from '../controllers'; | ||
// import { Authorization } from '../middlewares'; | ||
// import Validate from '../validation'; | ||
|
||
const accomodationRoutes = app => { | ||
app.post( | ||
'/api/v1/accomodation', | ||
// Validate.validateUserInput, | ||
// Authorization.checkToken, | ||
AccomodationController.createAccomodation | ||
); | ||
}; | ||
|
||
export default accomodationRoutes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters