-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (24 loc) · 806 Bytes
/
index.js
File metadata and controls
33 lines (24 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import fastify from 'fastify';
import { fetchPostJson } from './src/index.js'
const app = fastify();
const PORT = process.env.PORT || 3000
app.get('/', async (request, reply) => {
reply.send('/download/?url=Link-do-video-instagram');
});
app.get('/download/', async (request, reply) => {
const { url } = request.query;
console.log("--> GET /download", url, new Date().toLocaleString())
if (!url) reply.send({ error: 'forneça uma URL do instagram' })
let resultado = await fetchPostJson(url)
reply.send({ ...resultado });
});
const start = async () => {
try {
app.listen({ host: '0.0.0.0', port: PORT });
console.log('Servidor rodando em http://localhost:3000');
} catch (err) {
console.error(err);
process.exit(1);
}
};
start();