Skip to content

Commit

Permalink
feat(notes prototype): created route for notes and controller for handle
Browse files Browse the repository at this point in the history
  • Loading branch information
SouOWendel committed Jan 26, 2024
1 parent bcc9de8 commit 34f3299
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
16 changes: 16 additions & 0 deletions expressAPI/src/controllers/notes.js
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};
67 changes: 67 additions & 0 deletions expressAPI/src/routes/notes.js
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;

0 comments on commit 34f3299

Please sign in to comment.