mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
GetAllExperiences
This commit is contained in:
@ -0,0 +1,17 @@
|
|||||||
|
meta {
|
||||||
|
name: GetAllExperiences
|
||||||
|
type: http
|
||||||
|
seq: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: http://localhost:3000/api/experiences/
|
||||||
|
body: json
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"personId": 1
|
||||||
|
}
|
||||||
|
}
|
@ -3,5 +3,5 @@ auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auth:bearer {
|
auth:bearer {
|
||||||
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTc0OTcxNTI1MCwiZXhwIjoxNzQ5NzQ0MDUwfQ.s1Fn9-Ju5XayFq89MBaQ9AGVm7CIrVvUaDWbnfiBA54
|
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTc0OTcxNjg4MiwiZXhwIjoxNzQ5NzQ1NjgyfQ.fcvogRFGJtQLX3FKR_fylQRsJE-zhuLwn94J1TgwwkA
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# API server settings
|
# API server settings
|
||||||
API_SERVER_PORT = 3000
|
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_WINDOW = 3600000 # Milliseconds in limiter window
|
||||||
LIMITER_MAXIMUM_PER_WINDOW = 5000 # Requests for each limiter window
|
LIMITER_MAXIMUM_PER_WINDOW = 5000 # Requests for each limiter window
|
||||||
|
@ -60,6 +60,11 @@ async function update(experience) {
|
|||||||
.update(experience);
|
.update(experience);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getAllExperiences(person_id){
|
||||||
|
return await knex('Experience')
|
||||||
|
.where('person_id', person_id);
|
||||||
|
}
|
||||||
|
|
||||||
// Exporting a function
|
// Exporting a function
|
||||||
// means making a JavaScript function defined in one
|
// means making a JavaScript function defined in one
|
||||||
// module available for use in another module.
|
// module available for use in another module.
|
||||||
@ -68,5 +73,6 @@ module.exports = {
|
|||||||
insert,
|
insert,
|
||||||
find,
|
find,
|
||||||
remove,
|
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();
|
const routes = express.Router();
|
||||||
routes.post('/', jwtUtils.extractToken, insert);
|
routes.post('/', jwtUtils.extractToken, insert);
|
||||||
routes.get('/:experienceId', jwtUtils.extractToken, find);
|
routes.get('/:experienceId', jwtUtils.extractToken, find);
|
||||||
|
routes.get('/', jwtUtils.extractToken, allExperiences);
|
||||||
routes.delete('/:experienceId', jwtUtils.extractToken, remove);
|
routes.delete('/:experienceId', jwtUtils.extractToken, remove);
|
||||||
routes.patch('/:experienceId', jwtUtils.extractToken, update);
|
routes.patch('/:experienceId', jwtUtils.extractToken, update);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user