A src/environment.ts => src/environment.ts +2 -0
@@ 0,0 1,2 @@
+export const PRODUCTION: boolean = process.env.NODE_ENV == 'production';
+export const HOST: string = process.env.HOST ?? 'localhost';<
\ No newline at end of file
M src/index.ts => src/index.ts +19 -4
@@ 1,5 1,20 @@
-const test = () => {
- console.log("test");
-}
+import fastify from 'fastify';
+import autoLoad from '@fastify/autoload';
+import {HOST, PRODUCTION } from "./environment";
+import { join } from 'path';
-test();
+const server = fastify({
+ logger: !PRODUCTION,
+});
+
+void server.register(autoLoad, {
+ dir: join(__dirname, 'routes'),
+});
+
+server.listen({ port: 8080, host: HOST }, (err, address) => {
+ if (err) {
+ console.log(err);
+ process.exit(1);
+ }
+ console.log(`Server is starting on ${address}`);
+})<
\ No newline at end of file
A src/routes/.gitkeep => src/routes/.gitkeep +0 -0