-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
322 additions
and
36 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
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,5 +1,15 @@ | ||
# CHANGELOG | ||
|
||
### v0.1.0 / 2023-08-29 | ||
|
||
- Address route | ||
- Handle ldap client errors | ||
- Improve Docker image (speed and permissions) | ||
- Update prettier from 2.8.7 to 3.0.1 | ||
- Fix environment variables for Docker Compose | ||
- Fix 'node' engine requirement | ||
- Improve section deploy in documentation (Ansible) | ||
|
||
### v0.0.1 / 2023-08-02 | ||
|
||
- First version, released on an unsuspecting world. |
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
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 |
---|---|---|
|
@@ -46,6 +46,22 @@ | |
- [/api/ldap?q=278890][ldap-1] | ||
- [/api/ldap?q=[email protected]&hl=en][ldap-2] | ||
|
||
## Address | ||
|
||
### Endpoint | ||
|
||
`GET /api/address` | ||
|
||
### Parameters | ||
|
||
| Name | Type | Comments | | ||
| ---- | -------- | -------------- | | ||
| `q` | `String` | Query (sciper) | | ||
|
||
### Examples | ||
|
||
- [/api/address?q=278890][address-1] | ||
|
||
## Unit | ||
|
||
### Endpoint | ||
|
@@ -112,3 +128,4 @@ See [Contributing](CONTRIBUTING.md). | |
[graphsearch-1]: http://127.0.0.1:5555/api/graphsearch?q=math | ||
[graphsearch-2]: http://127.0.0.1:5555/api/graphsearch?q=vetterli&doctype=person | ||
[graphsearch-3]: http://127.0.0.1:5555/api/graphsearch?q=lts&doctype=unit | ||
[address-1]: http://127.0.0.1:5555/api/address?q=278890 |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"name": "search-api", | ||
"private": true, | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "EPFL Search Engine API", | ||
"repository": "epfl-si/search-api", | ||
"author": "William Belle <[email protected]>", | ||
"homepage": "https://github.com/epfl-si/search-api#readme", | ||
"engines": { | ||
"node": "^14.17.0 || >=16.0.0" | ||
"node": "^16.10.0 || >=18.0.0" | ||
}, | ||
"scripts": { | ||
"docs": "jsdoc -c jsdoc.json", | ||
|
@@ -16,8 +16,8 @@ | |
"prettier": "prettier --check --ignore-unknown '**' '!**/*.js' '!**/ansible-deps-cache'", | ||
"prettier:fix": "prettier --write --ignore-unknown '**' '!**/*.js' '!**/ansible-deps-cache'", | ||
"start": "nodemon src/server.js", | ||
"test": "npm run lint && jest --forceExit --verbose", | ||
"test:coverage": "jest --coverage --forceExit --verbose", | ||
"test": "npm run lint && jest --verbose", | ||
"test:coverage": "jest --coverage --verbose", | ||
"test:watch": "jest --watchAll --verbose" | ||
}, | ||
"devDependencies": { | ||
|
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
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,31 @@ | ||
const ldapUtil = require('../utils/ldap.util'); | ||
const addressService = require('../services/people.service'); | ||
const appCache = require('../services/cache.service'); | ||
|
||
async function get (req, res) { | ||
const q = req.query.q || ''; | ||
if (!/^[0-9]{6}$/.test(q)) { | ||
return res.json({}); | ||
} | ||
|
||
if (appCache.has(req.originalUrl)) { | ||
return res.send(appCache.get(req.originalUrl)); | ||
} else { | ||
try { | ||
const ldapResults = await addressService.getPersonBySciper(q); | ||
const jsonResponse = ldapUtil.ldapAddress2api(ldapResults); | ||
appCache.set(req.originalUrl, jsonResponse); | ||
return res.json(jsonResponse); | ||
} catch (err) { | ||
console.error('[error] ', err.message); | ||
return res.status(400).json({ | ||
success: false, | ||
error: 'Oops, something went wrong' | ||
}); | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
get | ||
}; |
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,8 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
|
||
const addressController = require('../controllers/address.controller'); | ||
|
||
router.get('/', addressController.get); | ||
|
||
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
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.