-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
47 lines (36 loc) · 917 Bytes
/
index.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import fastify, { FastifyInstance } from "fastify";
import { PrismaClient } from '@prisma/client'
const fastify_cors = require('@fastify/cors')
const prisma = new PrismaClient()
const app: FastifyInstance = fastify({
logger: true
})
app.register(fastify_cors, {
"origin": '*',
})
app.get('/health', (_, reply) => {
reply.send({ message: "Ok" })
})
app.get('/sendAction', async (_, reply) => {
const data = {
"action": "LESSON_VIEW",
"origin": "TOOLKIT",
"plataform": "WEB",
"data": "NOTHING",
"user": "1235-4433",
"entity": "213213-3213"
}
await prisma.tracker.create({
data: {
...data
}
})
reply.send({ success: true })
})
app.listen({ port: 3000 }, (err, address) => {
if (err) {
app.log.error(err);
process.exit(1);
}
app.log.info(`server listening on ${address}`)
})