• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CodeHex16 / Suppl-AI / 15071463608

16 May 2025 03:02PM UTC coverage: 81.09%. First build
15071463608

Pull #55

github

web-flow
Merge 99649ab05 into 1832a13c9
Pull Request #55: Test di unita e varie optimization

333 of 436 branches covered (76.38%)

Branch coverage included in aggregate %.

651 of 790 new or added lines in 54 files covered. (82.41%)

1974 of 2409 relevant lines covered (81.94%)

1.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.91
/src/routes/api/save_bot_message/+server.ts
1
import type { RequestHandler } from './$types';
2
import { json } from '@sveltejs/kit';
1✔
3
import { env } from '$env/dynamic/public';
1✔
4
import { logger } from '$lib/utils/logger';
1✔
5

6
const DATABASE_URL = env.PUBLIC_DATABASE_URL;
1✔
7

8
export const POST: RequestHandler = async ({ request, cookies }) => {
1✔
9
        logger.info('POST /api/save_bot_message');
6✔
10
        try {
6✔
11
                const req = await request.json();
6✔
12
                const token = cookies.get('token');
6✔
13
                logger.debug('req', req);
6✔
14

15
                if (!token) {
6✔
16
                        logger.error('Token non trovato');
1✔
17
                        return json({ error: 'Unauthorized' }, { status: 401 });
1✔
18
                }
1✔
19

20
                // Salva il messaggio del bot nel database
21
                const response = await fetch(`http://${DATABASE_URL}/chats/${req.chat_id}/messages`, {
5✔
22
                        method: 'POST',
5✔
23
                        headers: {
5✔
24
                                'Content-Type': 'application/json',
5✔
25
                                Authorization: `Bearer ${token}`
5✔
26
                        },
5✔
27
                        body: JSON.stringify({
5✔
28
                                content: req.content,
5✔
29
                                sender: 'bot'
5✔
30
                        })
5✔
31
                });
5!
32

33
                if (!response.ok) {
×
34
                        const errorData = await response.json();
×
NEW
35
                        logger.error('Errore durante il salvataggio del messaggio del bot', errorData);
×
36
                        return json(
×
37
                                { error: 'Failed to save bot message', details: errorData },
×
38
                                { status: response.status }
×
39
                        );
×
40
                }
×
41

42
                const data = await response.json();
×
NEW
43
                logger.info('Messaggio del bot salvato con successo', data);
×
44

45
                return json({ success: true, data: data });
×
46
        } catch (error) {
6✔
47
                logger.error('Errore durante il salvataggio del messaggio del bot:', error);
5✔
48
                return json({ error: 'Internal server error' }, { status: 500 });
5✔
49
        }
5✔
50
};
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc