-
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.
feat(notes prototype): created route for notes and controller for handle
- Loading branch information
1 parent
bcc9de8
commit 34f3299
Showing
2 changed files
with
83 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
import {authenticated} from '../services/auth.js'; | ||
|
||
const findAll = (request, response) => { | ||
try { | ||
authenticated(request.headers); | ||
|
||
return response.status(200).json({message: 'success!'}); | ||
} catch (error) { | ||
// Retorna o erro ou o código 500 (Internal Server Error). | ||
console.log('Error Custom:', error); | ||
return response.status(error.status || 500).json({message: error.message || 'Internal Error'}); | ||
} | ||
}; | ||
|
||
export {findAll}; |
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,67 @@ | ||
// import mongoose from 'mongoose'; | ||
import express from 'express'; | ||
import {authenticated} from '../services/auth.js'; | ||
|
||
// eslint-disable-next-line new-cap | ||
const router = express.Router(); | ||
|
||
router.get('/', async (request, response) => { | ||
const authd = authenticated(request.headers); | ||
console.log(authd); | ||
return response.send('alo'); | ||
}); | ||
|
||
// const Updates = mongoose.model('Notes', { | ||
// id: Number, | ||
// minCoreVersion: String, | ||
// maxCoreVersion: String, | ||
// minSysVersion: String, | ||
// maxSysVersion: String, | ||
// type: String, | ||
// display: String, | ||
// title: String, | ||
// content: String, | ||
// }); | ||
|
||
// router.get('/', async (request, response) => { | ||
// const notes = await Updates.find(); | ||
// return response.send(notes); | ||
// }); | ||
|
||
// router.post('/', async (request, response) => { | ||
// const notes = new Updates({ | ||
// id: request.body.id, | ||
// minCoreVersion: request.body.minCoreVersion, | ||
// maxCoreVersion: request.body.maxCoreVersion, | ||
// minSysVersion: request.body.minSysVersion, | ||
// maxSysVersion: request.body.maxSysVersion, | ||
// type: request.body.type, | ||
// display: request.body.display, | ||
// title: request.body.title, | ||
// content: request.body.content, | ||
// }); | ||
// response.send('OK!'); | ||
// return await notes.save(); | ||
// }); | ||
|
||
// router.put('/:id', async (request, response) => { | ||
// const note = await Updates.findByIdAndUpdate(request.params.id, { | ||
// id: request.body.id, | ||
// minCoreVersion: request.body.minCoreVersion, | ||
// maxCoreVersion: request.body.maxCoreVersion, | ||
// minSysVersion: request.body.minSysVersion, | ||
// maxSysVersion: request.body.maxSysVersion, | ||
// type: request.body.type, | ||
// display: request.body.display, | ||
// title: request.body.title, | ||
// content: request.body.content, | ||
// }, {new: true}); | ||
// return response.send(note); | ||
// }); | ||
|
||
// router.delete('/:id', async (request, response) => { | ||
// const note = await Updates.findByIdAndDelete(request.params.id); | ||
// return response.send(note); | ||
// }); | ||
|
||
export default router; |