mirror of
				https://github.com/xfarrow/blink
				synced 2025-06-27 09:03:02 +02:00 
			
		
		
		
	add personcontactinfo routes
This commit is contained in:
		| @@ -27,6 +27,7 @@ const jobOffersRoutes = require('./routes/job_offer_routes.js'); | ||||
| const serverRoutes = require('./routes/server_routes.js'); | ||||
| const resetPasswordRoutes = require('./routes/reset_password_routes.js'); | ||||
| const applicationRoutes = require('./routes/job_application_routes.js'); | ||||
| const personContactInfosRoutes = require('./routes/person_contact_info_routes.js'); | ||||
|  | ||||
| /* | ||||
| ===== END IMPORTING MODULES ===== | ||||
| @@ -57,6 +58,7 @@ app.use('/api/organizations', jobOffersRoutes.routes); | ||||
| app.use('/api/organizations', organizationAdminRoutes.routes); | ||||
| app.use('/api/resetpassword', resetPasswordRoutes.routes); | ||||
| app.use('/api/organizations', applicationRoutes.routes); | ||||
| app.use('/api/persons', personContactInfosRoutes.routes); | ||||
|  | ||||
| /* | ||||
| ===== END ROUTE HANDLING ===== | ||||
|   | ||||
							
								
								
									
										28
									
								
								backend/apis/nodejs/src/models/person_contact_info.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								backend/apis/nodejs/src/models/person_contact_info.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| /* | ||||
|     This code is part of Blink | ||||
|     licensed under GPLv3 | ||||
|  | ||||
|     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|     IMPLIED,  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||||
|     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||||
|     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||||
|     IN THE SOFTWARE. | ||||
| */ | ||||
|  | ||||
| const knex = require('../utils/knex_config'); | ||||
|  | ||||
| async function insert(personId, infoContent, infoType) { | ||||
|     return await knex('PersonContactInfo') | ||||
|         .insert({ | ||||
|             person_id: personId, | ||||
|             info: infoContent, | ||||
|             info_type: infoType | ||||
|         }) | ||||
|         .returning("*"); | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|     insert | ||||
| } | ||||
							
								
								
									
										35
									
								
								backend/apis/nodejs/src/routes/person_contact_info_routes.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								backend/apis/nodejs/src/routes/person_contact_info_routes.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| /* | ||||
|     This code is part of Blink | ||||
|     licensed under GPLv3 | ||||
|  | ||||
|     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|     IMPLIED,  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||||
|     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||||
|     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||||
|     IN THE SOFTWARE. | ||||
| */ | ||||
|  | ||||
| const express = require('express'); | ||||
| const jwtUtils = require('../utils/jwt_utils'); | ||||
| const PersonContactInfo = require('../models/person_contact_info'); | ||||
|  | ||||
| async function insert(req, res) { | ||||
|     try { | ||||
|         const contactInfo = PersonContactInfo.insert(req.jwt.person_id, req.body.content, req.body.info_type); | ||||
|         res.set('Location', `/api/persons/${req.jwt.person_id}/contactinfos/${contactInfo.id}`); | ||||
|         return res.status(201).json(application); | ||||
|     } catch (error) { | ||||
|         console.error(`Error in function ${insert.name}: ${error}`); | ||||
|         res.status(500).json({ | ||||
|             error: 'Internal server error' | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|  | ||||
| const routes = express.Router(); | ||||
| routes.post('/myself/contactinfos', jwtUtils.extractToken, insert); | ||||
| module.exports = { | ||||
|     routes | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user