mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
45 lines
807 B
JavaScript
45 lines
807 B
JavaScript
const express = require('express')
|
|
|
|
const router = module.exports.router = express.Router();
|
|
|
|
function serializeNote(note) {
|
|
return {
|
|
title: note.title,
|
|
body: note.body
|
|
};
|
|
}
|
|
|
|
router.post('/find', async (req, res) => {
|
|
const notes = await Note.find({
|
|
ownerToken: req.body.token
|
|
}).exec();
|
|
res.json({
|
|
notes: notes.map(serializeNote)
|
|
});
|
|
});
|
|
|
|
router.get('/findPublic', async (_req, res) => {
|
|
const notes = await Note.find({
|
|
isPublic: true
|
|
}).exec();
|
|
res.json({
|
|
notes: notes.map(serializeNote)
|
|
});
|
|
});
|
|
|
|
router.post('/findVisible', async (req, res) => {
|
|
const notes = await Note.find({
|
|
$or: [
|
|
{
|
|
isPublic: true
|
|
},
|
|
{
|
|
ownerToken: req.body.token
|
|
}
|
|
]
|
|
}).exec();
|
|
res.json({
|
|
notes: notes.map(serializeNote)
|
|
});
|
|
});
|