Skip to content

Commit

Permalink
wip: server
Browse files Browse the repository at this point in the history
  • Loading branch information
VilemRaska committed Jan 25, 2025
1 parent ab3236b commit 9048dd7
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
10 changes: 6 additions & 4 deletions GAPP/apps/gapp-server/src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import * as path from 'path';
import { FastifyInstance } from 'fastify';
import AutoLoad from '@fastify/autoload';

/* eslint-disable-next-line */
export interface AppOptions {}
export interface AppOptions {
influxDbToken: string;
influxDbHost: string;
}

export async function app(fastify: FastifyInstance, opts: AppOptions) {
export const app = async (fastify: FastifyInstance, opts: AppOptions) => {
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
options: { ...opts },
Expand All @@ -15,4 +17,4 @@ export async function app(fastify: FastifyInstance, opts: AppOptions) {
dir: path.join(__dirname, 'routes'),
options: { ...opts },
});
}
};
8 changes: 7 additions & 1 deletion GAPP/apps/gapp-server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import Fastify from 'fastify';
import { app } from './app/app';
import { getConfig } from './config';
import pino from 'pino';
import { Uploader } from '@gapp/sondehub';

console.log(Uploader);

const config = getConfig(process.env);
const logger = pino();
const server = Fastify({ loggerInstance: logger });

server.register(app);
server.register(app, {
influxDbToken: config.INFLUXDB_TOKEN,
influxDbHost: config.INFLUXDB_HOST,
});

server.listen({ port: config.PORT, host: '0.0.0.0' }, (err) => {
if (err) {
Expand Down
1 change: 0 additions & 1 deletion GAPP/apps/gapp-server/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"]
},
"include": ["src/**/*.ts"],
Expand Down
1 change: 0 additions & 1 deletion GAPP/apps/gapp-server/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"moduleResolution": "node10",
"types": ["jest", "node"]
},
Expand Down
2 changes: 1 addition & 1 deletion GAPP/eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ module.exports = [
// Override or add rules here
rules: {},
},
eslintConfigPrettier
eslintConfigPrettier,
];
1 change: 0 additions & 1 deletion GAPP/libs/sondehub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.0.1",
"private": true,
"dependencies": {},
"type": "commonjs",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion GAPP/libs/sondehub/src/lib/sondehub.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('sondehub', () => {
it('should work', () => {
expect(true).toBeTruthy();
expect(true).toBeTruthy();
});
});
4 changes: 3 additions & 1 deletion GAPP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
"name": "@gapp/source",
"version": "0.0.0",
"license": "MIT",
"type": "module",
"scripts": {
"dashboard:dev": "nx serve gapp-dashboard",
"dashboard:build": "nx build gapp-dashboard",
"server:dev": "nx serve gapp-server | pino-pretty",
"server:build": "nx build gapp-server",
"format": "nx format:write"
"format": "nx format:write",
"server:start": "node dist/apps/gapp-server/main.js"
},
"private": true,
"dependencies": {
Expand Down

0 comments on commit 9048dd7

Please sign in to comment.