-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfastify.ts
More file actions
39 lines (31 loc) · 744 Bytes
/
fastify.ts
File metadata and controls
39 lines (31 loc) · 744 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
34
35
36
37
38
39
import Fastify from 'fastify';
const main = async () => {
const app = Fastify({
logger: true,
bodyLimit: 100 * 1024 * 1024,
});
app.post<{
Body: {
files: any[],
},
}>('/example', (_req, res) => {
console.log('Success!');
res.send({
success: true,
});
});
app.setNotFoundHandler((req, reply) => {
reply.code(404).send({
error: 'Not Found',
message: `Route ${req.method} ${req.url} not found`,
});
});
const host = 'localhost';
const port = '3000';
console.log('Starting Web Server on ' + host + ':' + port+ '...');
app.listen({
host,
port,
});
}
main();