-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create route for multi-city trip request add validations create a table model and trips create routew for posting locations [Finishes 169258638]
- Loading branch information
Showing
47 changed files
with
1,262 additions
and
597 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import dotenv from 'dotenv'; | ||
import Customize from '../helpers/Customize'; | ||
import { cities } from '../database/models'; | ||
import DataEngine from '../middlewares/DataEngine'; | ||
|
||
dotenv.config(); | ||
/** | ||
* @export | ||
* @class LocationController | ||
*/ | ||
class LocationController { | ||
/** | ||
* An admin should be able to add locations | ||
* @static | ||
* @param {object} req request object | ||
* @param {object} res response object | ||
* @memberof LocationController | ||
* @returns {object} data | ||
*/ | ||
static async saveLocation(req, res) { | ||
try { | ||
const { name } = req.body; | ||
|
||
const newLocation = await cities.create({ | ||
city: name | ||
}); | ||
|
||
|
||
return Customize.successMessage(req, res, 'Location posted successfully', newLocation, 201); | ||
} catch (err) { | ||
return Customize.errorMessage(req, res, err.message, 500); | ||
} | ||
} | ||
} | ||
export default LocationController; |
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
Oops, something went wrong.