Compare commits

..

No commits in common. '1ed359f602f9cb407a9b74fa9296dc255ff3633c' and 'dc3a682a77b8f5c9c95823835476e1bb07f95506' have entirely different histories.

@ -3,12 +3,12 @@ type: docker
name: build dev
steps:
- name: build for staging
- name: build and push image
image: plugins/docker
settings:
dockerfile: Dockerfile
registry: hub.fsisp.de
repo: hub.fsisp.de/library/iassure-wx
registry: git.fsisp.de
repo: git.fsisp.de/fionn/iassure-wx
username:
from_secret: reg_username
password:
@ -16,27 +16,32 @@ steps:
tags:
- dev
- '${DRONE_COMMIT:0:8}'
when:
branch:
- dev
- develop
event:
- push
- name: build for production
trigger:
branch:
- dev
- develop
---
kind: pipeline
type: docker
name: build master
steps:
- name: build and push image
image: plugins/docker
settings:
dockerfile: Dockerfile
registry: hub.fsisp.de
repo: hub.fsisp.de/library/iassure-wx
registry: git.fsisp.de
repo: git.fsisp.de/fionn/iassure-wx
username:
from_secret: reg_username
password:
from_secret: reg_password
tags:
- latest
- '${DRONE_TAG}'
- '${DRONE_COMMIT:0:8}'
when:
event:
- tag
trigger:
branch:
- main

@ -6,7 +6,7 @@ This service is designed to gather weather data to be used by [IASsure](https://
## Installation/Deployment
IASsure-WX can be installed using docker. The image is available at `hub.fsisp.de/library/iassure-wx`.
IASsure-WX can be installed using docker. The image is available at `git.fsisp.de/fionn/iassure-wx`.
Tags:
- `latest` - The newest recommended build, built from `main`
@ -28,7 +28,5 @@ PORT=3000
BASE_PATH=/api
# defines ips that are allowed as proxy ips
# See http://expressjs.com/en/guide/behind-proxies.html
TRUST_PROXY=
# set to true to disable /api-Endpoint. will also disable frontend.
DISABLE_DEFAULT_API_ENDPOINT=
TRUST_PROXY_ID=
```

@ -1,6 +1,6 @@
{
"name": "app",
"version": "1.2.0",
"version": "1.1.0",
"description": "",
"main": "index.js",
"type": "module",

@ -3,26 +3,19 @@ import nodesched from 'node-schedule';
import morgan from 'morgan';
import router from './router';
import wxService from './services/wx.service';
import appConfig from './config';
const app = express();
const { PORT = 3000, BASE_PATH = '/api', TRUST_PROXY_IP = false } = process.env;
const config = appConfig();
const app = express();
app.set('trust proxy', config.trustProxy);
app.set('trust proxy', TRUST_PROXY_IP);
app.use(morgan('combined'));
if (config.apiBasePath) {
app.use(config.apiBasePath, router.router);
}
if (!config.disableDefaultApiEndpoint) {
app.use('/api', router.router);
app.use(BASE_PATH, router.router);
const frontendRoot = '/opt/frontend/dist';
app.use(express.static(frontendRoot));
app.use((req, res) => res.sendFile(`${frontendRoot}/index.html`));
}
const frontendRoot = '/opt/frontend/dist';
app.use(express.static(frontendRoot));
app.use((req, res) => res.sendFile(`${frontendRoot}/index.html`));
// eslint-disable-next-line @typescript-eslint/no-unused-vars
app.use((err, req: Request, res: Response, next: NextFunction) => {
@ -35,13 +28,13 @@ app.use((err, req: Request, res: Response, next: NextFunction) => {
nodesched.scheduleJob('regenerate data', '*/30 * * * * *', wxService.wrappedGenerateData);
wxService.wrappedGenerateData();
const server = app.listen(config.port, () => {
const server = app.listen(PORT, () => {
console.log(
`application is listening on port ${config.port}`,
`application is listening on port ${PORT}`,
);
});
function processShutdown(signal: string) {
const shutdown = (signal: string) => {
console.log(`${signal} signal received. Shutting down.`);
server.close((err) => {
if (err) {
@ -52,6 +45,7 @@ function processShutdown(signal: string) {
console.log('Server closed');
process.exit(0);
});
}
};
['SIGTERM', 'SIGINT'].map(signal => process.on(signal, processShutdown.bind(undefined, signal)));
process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGINT', () => shutdown('SIGINT'));

@ -1,28 +0,0 @@
export interface Config {
port: number;
apiBasePath: string;
disableDefaultApiEndpoint: boolean;
trustProxy: string | boolean;
}
export default function appConfig(): Config {
const {
PORT,
BASE_PATH,
TRUST_PROXY,
DISABLE_DEFAULT_API_ENDPOINT,
} = process.env;
let trustProxy: string | boolean = false;
if (TRUST_PROXY == '*') {
trustProxy = true;
}
return {
port: Number(PORT ?? 3000),
apiBasePath: BASE_PATH ?? '',
trustProxy,
disableDefaultApiEndpoint: DISABLE_DEFAULT_API_ENDPOINT == 'true',
};
}
Loading…
Cancel
Save