-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (31 loc) · 920 Bytes
/
server.js
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
import Fastify from 'fastify'
const fastify = Fastify({
logger: true,
bodyLimit: 104857600
})
import {SERVER_PORT} from './js/config.js';
import fastify_formbody from '@fastify/formbody';
import fastify_multipart from '@fastify/multipart';
import fastify_cors from '@fastify/cors';
import {maple} from './routes/maple.js';
// 맨 마지막에 실행.
fastify.register(fastify_multipart, { attachFieldsToBody: true });
fastify.register(fastify_formbody);
fastify.register(fastify_cors,{ origin:true });
fastify.register(maple);
// Declare a route
fastify.get('/', async (request, reply) => {
return { hello: 'world' }
});
// Run the server!
const start = async () => {
try {
await fastify.listen({ host: '0.0.0.0', port: SERVER_PORT })
} catch (err) {
fastify.log.error(err);
process.exit(1);
} finally {
// 종료할때 실행되는지 확인.
}
};
start();