-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create get locatoins router with thier quiery, cotroller and it's test
Relates #88
- Loading branch information
Showing
9 changed files
with
53 additions
and
0 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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
const { clientError, serverError } = require('./errorHandle'); | ||
const { getSpecificKindergarten } = require('./kindergarten'); | ||
const { getUsers } = require('./users'); | ||
const { getLocations } = require('./locations'); | ||
|
||
module.exports = { | ||
clientError, | ||
serverError, | ||
getUsers, | ||
getSpecificKindergarten, | ||
getLocations, | ||
}; |
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,12 @@ | ||
const { getLocatoinsQuery } = require('../../../database/queries'); | ||
|
||
const getLocations = async (req, res, next) => { | ||
try { | ||
const { rows: data } = await getLocatoinsQuery(); | ||
res.json({ statusCode: 200, data }); | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
|
||
module.exports = getLocations; |
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,3 @@ | ||
const getLocations = require('./getLocations'); | ||
|
||
module.exports = { getLocations }; |
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,7 +1,9 @@ | ||
const { getKindergartenById } = require('./kindergarten'); | ||
const { getUsersQuery } = require('./users'); | ||
const { getLocatoinsQuery } = require('./locations'); | ||
|
||
module.exports = { | ||
getKindergartenById, | ||
getUsersQuery, | ||
getLocatoinsQuery, | ||
}; |
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,10 @@ | ||
const connection = require('../../../data/connection'); | ||
|
||
const getLocatoinsQuery = () => { | ||
const sql = { | ||
text: 'SELECT id,location_sub,location_main FROM locations', | ||
}; | ||
return connection.query(sql); | ||
}; | ||
|
||
module.exports = getLocatoinsQuery; |
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,3 @@ | ||
const getLocatoinsQuery = require('./getLocations'); | ||
|
||
module.exports = { getLocatoinsQuery }; |
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,8 +1,10 @@ | ||
const router = require('express').Router(); | ||
const kindergarten = require('./kindergarten'); | ||
const user = require('./user'); | ||
const location = require('./location'); | ||
|
||
router.use(user); | ||
router.use(kindergarten); | ||
router.use(location); | ||
|
||
module.exports = router; |
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,7 @@ | ||
const router = require('express').Router(); | ||
|
||
const { getLocations } = require('../controllers'); | ||
|
||
router.get('/locations', getLocations); | ||
|
||
module.exports = router; |
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