Skip to content

Commit

Permalink
Feat: routes check certified (#7)
Browse files Browse the repository at this point in the history
Co-authored-by: Reginaldo Junior <[email protected]>
  • Loading branch information
reginaldojunior and reginaldojuniorcreditas authored Jan 27, 2025
1 parent 38546b0 commit df9ca9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ const app = express();
const bodyParser = require('body-parser');
const router = express.Router();
const database = require('../config/database');
const cors = require('cors');

//Rotas
const index = require('./routes/index');
const certified = require('./routes/certifiedRoute');

app.use(cors({
origin: ['http://localhost:4000', 'https://quebra.dev']
}))

app.use(bodyParser());

app.use('/', index);
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/certified.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports.getValidHash = (req, res, next) => {
}

certificates.findOne({ hash: req.params.hashId }).then(async (result) => {
res.status(200).json({"certified_valid": true});
res.status(200).json({ certified_valid: !!result });
}).catch((error) => {
res.status(404).json(error);
})
Expand All @@ -36,7 +36,7 @@ exports.getCertifiedByRG = (req, res, next) => {
let rgCripted = createHash("sha256").update(req.params.rg).digest("hex")

certificates.findOne({ documents: { rg: rgCripted } }).then(async (result) => {
res.status(200).json({"certified_valid": true});
res.status(200).json({ certified_valid: !!result });
}).catch((error) => {
res.status(404).json(error);
})
Expand Down

0 comments on commit df9ca9e

Please sign in to comment.