mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
feat: migrate to esm
This commit is contained in:
2
backend/proxy/app.js
Normal file
2
backend/proxy/app.js
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
import './lib/cli.js'
|
||||
@@ -13,7 +13,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ConfigFile} from '../src/common';
|
||||
import {ConfigFile} from '../src/common.js';
|
||||
|
||||
const config: ConfigFile = {
|
||||
activeVersions: ['1\\.0\\.\\d+', '2\\.0\\.\\d+'],
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "@openstapps/proxy",
|
||||
"description": "NGINX proxy that is dynamically configured by a Node.js script",
|
||||
"version": "2.1.0",
|
||||
"type": "module",
|
||||
"license": "AGPL-3.0-only",
|
||||
"repository": "git@gitlab.com:openstapps/proxy.git",
|
||||
"author": "Anselm Rochus Stordeur <anselmstordeur@gmail.com>",
|
||||
@@ -13,12 +14,11 @@
|
||||
"Michel Jonathan Schmitz <michel.schmitz_1992@hotmail.com>",
|
||||
"Rainer Killinger <mail-openstapps@killinger.co>"
|
||||
],
|
||||
"main": "./lib/cli.js",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"build": "npm run lint && npm run compile",
|
||||
"build": "rimraf lib && tsc",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
|
||||
"check-configuration": "openstapps-configuration",
|
||||
"compile": "rimraf lib && tsc",
|
||||
"documentation": "typedoc --includeVersion --out docs --readme README.md --entryPointStrategy expand src",
|
||||
"lint": "eslint --ext .ts src/",
|
||||
"postversion": "npm run changelog",
|
||||
@@ -69,8 +69,8 @@
|
||||
"proxyquire": "2.1.3",
|
||||
"rimraf": "3.0.2",
|
||||
"ts-node": "10.9.1",
|
||||
"typedoc": "0.22.18",
|
||||
"typescript": "4.4.4"
|
||||
"typedoc": "0.23.26",
|
||||
"typescript": "4.8.4"
|
||||
},
|
||||
"nyc": {
|
||||
"all": true,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -18,9 +16,9 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {execSync} from 'child_process';
|
||||
import * as Dockerode from 'dockerode';
|
||||
import {render} from 'mustache';
|
||||
import {asyncReadFile, asyncWriteFile} from './common';
|
||||
import {getContainers, getTemplateView} from './main';
|
||||
import mustache from 'mustache';
|
||||
import {asyncReadFile, asyncWriteFile} from './common.js';
|
||||
import {getContainers, getTemplateView} from './main.js';
|
||||
|
||||
/* eslint-disable unicorn/prefer-module */
|
||||
|
||||
@@ -58,7 +56,7 @@ async function updateNginxConfig() {
|
||||
await delay(10_000);
|
||||
|
||||
// render nginx config file
|
||||
const nginxConfig = render(
|
||||
const nginxConfig = mustache.render(
|
||||
await asyncReadFile('nginx.conf.template', 'utf8'),
|
||||
await getTemplateView(containers),
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {SMTP} from '@openstapps/logger/lib/smtp';
|
||||
import {SMTP} from '@openstapps/logger/lib/smtp.js';
|
||||
import config from 'config';
|
||||
import {existsSync, readFile, writeFile} from 'fs';
|
||||
import {promisify} from 'util';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import Dockerode from 'dockerode';
|
||||
import isCidr from 'is-cidr';
|
||||
import {render} from 'mustache';
|
||||
import mustache from 'mustache';
|
||||
import path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import {
|
||||
@@ -28,14 +28,13 @@ import {
|
||||
sslHardeningParameters,
|
||||
SupportedLogFormats,
|
||||
TemplateView,
|
||||
} from './common';
|
||||
} from './common.js';
|
||||
// @ts-expect-error missing type defs
|
||||
import nodePortScanner from 'node-port-scanner';
|
||||
|
||||
/* eslint-disable unicorn/prefer-module */
|
||||
/* eslint-disable unicorn/no-await-expression-member */
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const nodePortScanner = require('node-port-scanner');
|
||||
|
||||
/**
|
||||
* Checks if a ContainerInfo matches a name and version regex
|
||||
*
|
||||
@@ -263,7 +262,7 @@ export async function generateMetricsServer(logFormat: string, enableMetrics?: b
|
||||
async function renderTemplate(path: string, view: unknown): Promise<string> {
|
||||
const content = await asyncReadFile(path, 'utf8');
|
||||
|
||||
return render(content, view);
|
||||
return mustache.render(content, view);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ import {Logger} from '@openstapps/logger';
|
||||
import {expect} from 'chai';
|
||||
import {mkdirSync, writeFileSync, unlinkSync, rmdirSync} from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { isFileType } from '../src/common';
|
||||
import { isFileType } from '../src/common.js';
|
||||
|
||||
process.on('unhandledRejection', async (error) => {
|
||||
await Logger.error(error);
|
||||
|
||||
@@ -24,7 +24,7 @@ import {expect} from 'chai';
|
||||
import chaiSpies from 'chai-spies';
|
||||
import {ContainerInfo} from 'dockerode';
|
||||
import {slow, suite, test, timeout} from '@testdeck/mocha';
|
||||
import {sslHardeningParameters, protocolHardeningParameters, SSLFilePaths} from './../src/common';
|
||||
import {sslHardeningParameters, protocolHardeningParameters, SSLFilePaths} from './../src/common.js';
|
||||
import {
|
||||
containerMatchesRegex,
|
||||
generateUpstreamMap,
|
||||
@@ -33,7 +33,7 @@ import {
|
||||
generateListener,
|
||||
generateMetricsServer,
|
||||
getContainers,
|
||||
} from '../src/main';
|
||||
} from '../src/main.js';
|
||||
import {resolve} from 'path';
|
||||
import {mkdirSync, writeFileSync, unlinkSync, rmdirSync} from 'fs';
|
||||
import proxyquire from 'proxyquire';
|
||||
|
||||
Reference in New Issue
Block a user