remove fastify endpoint
This commit is contained in:
parent
94912cde3e
commit
0668735a35
@ -76,8 +76,6 @@ fastify.register(require("./feedback/server"), { pb });
|
||||
fastify.register(require("./create-watchlist/server"), { pb });
|
||||
fastify.register(require("./delete-watchlist/server"), { pb });
|
||||
fastify.register(require("./edit-name-watchlist/server"), { pb });
|
||||
fastify.register(require("./get-notifications/server"), { pb });
|
||||
fastify.register(require("./update-notifications/server"), { pb });
|
||||
fastify.register(require("./create-strategy/server"), { pb });
|
||||
fastify.register(require("./delete-strategy/server"), { pb });
|
||||
fastify.register(require("./all-strategies/server"), { pb });
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
// Declare a route
|
||||
module.exports = function (fastify, opts, done) {
|
||||
|
||||
const pb = opts.pb;
|
||||
|
||||
fastify.post('/get-notifications', async (request, reply) => {
|
||||
const data = request.body;
|
||||
|
||||
const userId = data?.userId;
|
||||
let output;
|
||||
|
||||
try {
|
||||
output = await pb.collection("notifications").getFullList({
|
||||
filter: `opUser="${userId}" && readed = false`,
|
||||
expand: 'user,post,comment',
|
||||
sort: '-created'
|
||||
});
|
||||
|
||||
}
|
||||
catch(e) {
|
||||
//console.log(e)
|
||||
output = []
|
||||
}
|
||||
|
||||
reply.send({ items: output })
|
||||
|
||||
});
|
||||
|
||||
done();
|
||||
};
|
||||
@ -1,29 +0,0 @@
|
||||
// Declare a route
|
||||
module.exports = function (fastify, opts, done) {
|
||||
|
||||
const pb = opts.pb;
|
||||
|
||||
fastify.post('/update-notifications', async (request, reply) => {
|
||||
const data = request.body;
|
||||
|
||||
const notificationList = data?.unreadList;
|
||||
let output;
|
||||
|
||||
try {
|
||||
const itemsToUpdate = notificationList?.filter(item => !item.readed);
|
||||
// Perform updates in parallel
|
||||
await Promise.all(itemsToUpdate.map(item =>
|
||||
pb.collection("notifications").update(item, { readed: 'true' })
|
||||
));
|
||||
|
||||
output = 'success'
|
||||
}
|
||||
catch(e) {
|
||||
output = 'failure';
|
||||
}
|
||||
|
||||
reply.send({ items: output })
|
||||
});
|
||||
|
||||
done();
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user