mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
GetAllExperiences
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
# API server settings
|
||||
API_SERVER_PORT = 3000
|
||||
|
||||
JWT_SECRET_KEY = jwt-secret # Change this in production
|
||||
JWT_SECRET_KEY = CHANGE_ME # Change this in production
|
||||
|
||||
LIMITER_WINDOW = 3600000 # Milliseconds in limiter window
|
||||
LIMITER_MAXIMUM_PER_WINDOW = 5000 # Requests for each limiter window
|
||||
|
@ -60,6 +60,11 @@ async function update(experience) {
|
||||
.update(experience);
|
||||
}
|
||||
|
||||
async function getAllExperiences(person_id){
|
||||
return await knex('Experience')
|
||||
.where('person_id', person_id);
|
||||
}
|
||||
|
||||
// Exporting a function
|
||||
// means making a JavaScript function defined in one
|
||||
// module available for use in another module.
|
||||
@ -68,5 +73,6 @@ module.exports = {
|
||||
insert,
|
||||
find,
|
||||
remove,
|
||||
update
|
||||
update,
|
||||
getAllExperiences
|
||||
};
|
@ -110,9 +110,22 @@ async function update(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
async function allExperiences(req, res){
|
||||
try {
|
||||
const experiences = await Experience.getAllExperiences(req.body.personId);
|
||||
return res.status(200).json(experiences);
|
||||
} catch (error) {
|
||||
console.error(`Error in function ${remove.name}: ${error}`);
|
||||
res.status(500).json({
|
||||
error: 'Internal server error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const routes = express.Router();
|
||||
routes.post('/', jwtUtils.extractToken, insert);
|
||||
routes.get('/:experienceId', jwtUtils.extractToken, find);
|
||||
routes.get('/', jwtUtils.extractToken, allExperiences);
|
||||
routes.delete('/:experienceId', jwtUtils.extractToken, remove);
|
||||
routes.patch('/:experienceId', jwtUtils.extractToken, update);
|
||||
|
||||
|
Reference in New Issue
Block a user