change license, restructure

develop
Fionn 1 year ago
parent db4731e1af
commit bbf41f41a9

@ -5,48 +5,45 @@ FROM node:16-alpine as base
WORKDIR /opt
COPY . .
ENV NODE_ENV production
WORKDIR /opt/backend
RUN apk update && \
apk upgrade && \
npm i npm@latest -g && \
chown node:node -R /opt
# && \
# apk add --no-cache bash && \
# apk add --no-cache git && \
ARG NODE_ENV=production
ENV NODE_ENV ${NODE_ENV}
COPY --chown=node:node package*.json ./
RUN npm i npm@latest -g
RUN chown node:node -R /opt
USER node
# ################################################################
# ### development image ###
# ### build image ###
# ################################################################
FROM base as development
RUN npm install --quiet --unsafe-perm --no-progress --no-audit --include=dev
CMD npm run dev
FROM base as build
# ################################################################
# ### backend build image ###
# ################################################################
ENV NODE_ENV development
FROM base as backendbuild
COPY --chown=node:node . .
RUN npm install --quiet --unsafe-perm --no-progress --no-audit --include=dev
RUN npm install && npm cache clean --force
ENV PATH /opt/node_modules/.bin:$PATH
RUN npx tsc -p ./tsconfig.json
RUN tsc -p ./tsconfig.node.json && \
resolve-tspaths --out "dist" && \
npm run spa-build
# ################################################################
# ### frontend build image ###
# ### modules image ###
# ################################################################
FROM base as frontendbuild
WORKDIR /opt/frontend
RUN npm install --quiet --unsafe-perm --no-progress --no-audit --include=dev
FROM base as modules
RUN npm run build
RUN npm install && npm cache clean --force
# ################################################################
# ### production image ###
@ -54,9 +51,9 @@ RUN npm run build
FROM base as production
COPY --from=backendbuild --chown=node:node /opt/backend/dist/ /opt/backend/dist/
COPY --from=frontendbuild --chown=node:node /opt/frontend/dist/ /opt/frontend/dist/
COPY --from=build --chown=node:node /opt/dist ./dist
COPY --from=modules --chown=node:node /opt/node_modules ./node_modules
RUN npm install --quiet --unsafe-perm --no-progress --no-audit --omit=dev
COPY --chown=node:node ./wx-config.* ./
CMD node --es-module-specifier-resolution=node dist/backend/src/app.js
CMD node dist/backend/app.js

@ -1,31 +0,0 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": [
"airbnb-typescript/base",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"import",
"promise"
],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"eol-last": [
"error",
"always"
]
}
}

@ -1,39 +0,0 @@
{
"name": "app",
"version": "1.3.1",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"predev": "npm install && rimraf dist/*",
"prestart": "resolve-tspaths --out \"/opt/backend/dist/backend/src\"",
"start": "node --inspect=0.0.0.0:9229 dist/backend/src/app.js",
"dev": "tsc-watch --onSuccess \"npm run start\" --onFailure \"echo WHOOPS! Server compilation failed\""
},
"keywords": [],
"author": "Fionn Sperath",
"license": "ISC",
"dependencies": {
"axios": "^1.3.4",
"express": "^4.18.1",
"morgan": "^1.10.0",
"node-schedule": "^2.1.1"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/morgan": "^1.9.4",
"@types/node": "^18.7.6",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"eslint": "^8.23.1",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-promise": "^6.0.1",
"rimraf": "^3.0.2",
"tsc-watch": "^5.0.3",
"resolve-tspaths": "^0.8.8",
"typescript": "^4.7.4"
}
}

@ -5,9 +5,10 @@ services:
build:
context: .
dockerfile: ./Dockerfile
target: development
target: build
args:
- NODE_ENV=development
command: npm run dev
ports:
- '3030:3000/tcp'
- '9229:9229/tcp'

@ -1,35 +0,0 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": [
"airbnb-typescript/base",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"import",
"promise"
],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"import/extensions": "off",
"eol-last": [
"error",
"always"
]
},
"ignorePatterns": [
"**/vite.config.ts"
]
}

@ -1,24 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

File diff suppressed because it is too large Load Diff

@ -1,38 +0,0 @@
{
"name": "frontend",
"private": true,
"version": "1.3.1",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.4.0",
"bootstrap": "^5.2.3",
"leaflet": "^1.9.3",
"react": "^18.2.0",
"react-bootstrap": "^2.7.4",
"react-dom": "^18.2.0",
"react-leaflet": "^4.2.1",
"react-router": "^6.11.1"
},
"devDependencies": {
"@types/leaflet": "^1.9.3",
"@types/node": "^18.16.3",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"@vitejs/plugin-react": "^3.0.0",
"eslint": "^8.23.1",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-promise": "^6.0.1",
"eslint-plugin-react": "^7.31.11",
"typescript": "^4.9.4",
"vite": "^4.0.0"
}
}

@ -1,24 +0,0 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"paths": {
"@shared/*": ["../shared/src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

@ -1,9 +0,0 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,106 @@
{
"name": "iassure-wx",
"version": "1.3.2",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"paths": "resolve-tspaths --out \"dist\"",
"start": "resolve-tspaths --out \"dist\" && node --inspect=0.0.0.0:9229 dist/backend/app.js",
"dev": "tsc-watch -p ./tsconfig.node.json --onSuccess \"npm run start\" --onFailure \"echo WHOOPS! Server compilation failed\"",
"spa-dev": "vite --config=src/frontend/vite.config.ts",
"spa-build": "tsc -p ./tsconfig.web.json && vite --config=src/frontend/vite.config.ts build",
"spa-preview": "vite --config=src/frontend/vite.config.ts"
},
"keywords": [],
"author": "Fionn Sperath",
"license": "AGPL-3.0-only",
"dependencies": {
"axios": "^1.3.4",
"express": "^4.18.1",
"morgan": "^1.10.0",
"node-schedule": "^2.1.1"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/leaflet": "^1.9.3",
"@types/morgan": "^1.9.4",
"@types/node": "^18.16.3",
"@types/react-dom": "^18.0.9",
"@types/react": "^18.0.26",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"@vitejs/plugin-react": "^3.0.0",
"bootstrap": "^5.2.3",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-promise": "^6.0.1",
"eslint-plugin-react": "^7.31.11",
"eslint": "^8.23.1",
"leaflet": "^1.9.3",
"react-bootstrap": "^2.7.4",
"react-dom": "^18.2.0",
"react-leaflet": "^4.2.1",
"react-router": "^6.11.1",
"react": "^18.2.0",
"resolve-tspaths": "^0.8.8",
"rimraf": "^3.0.2",
"tsc-watch": "^5.0.3",
"typescript": "^4.9.4",
"vite": "^4.0.0"
},
"eslintConfig": {
"env": {
"es2021": true,
"node": true
},
"extends": [
"airbnb-typescript/base",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"import",
"promise"
],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": [
"./tsconfig.node.json",
"./tsconfig.web.json"
]
},
"rules": {
"no-console": "warn",
"import/extensions": "off",
"eol-last": [
"error",
"always"
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
],
"import/order": [
"error",
{
"newlines-between": "always",
"alphabetize": {
"order": "asc"
}
}
],
"@typescript-eslint/ban-ts-comment": "off"
}
}
}

@ -1,31 +0,0 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": [
"airbnb-typescript/base",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"import",
"promise"
],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"eol-last": [
"error",
"always"
]
}
}

@ -1,10 +0,0 @@
{
"devDependencies": {
"@types/node": "^18.6.2",
"eslint": "^8.23.1",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-promise": "^6.0.1"
}
}

@ -1,16 +0,0 @@
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "dist",
"baseUrl": "./src",
"module": "ES2022",
"target": "ES2022",
"lib": ["ES2022"],
"sourceMap": true,
"strictNullChecks": true,
"noImplicitAny": false,
"preserveConstEnums": true,
"removeComments": true,
"forceConsistentCasingInFileNames": true
}
}

@ -1,9 +1,10 @@
import express, { NextFunction, Request, Response } from 'express';
import nodesched from 'node-schedule';
import morgan from 'morgan';
import nodesched from 'node-schedule';
import appConfig from './config';
import router from './router';
import wxService from './services/wx.service';
import appConfig from './config';
const app = express();
@ -19,7 +20,7 @@ if (config.apiBasePath) {
if (!config.disableDefaultApiEndpoint) {
app.use('/api', router.router);
const frontendRoot = '/opt/frontend/dist';
const frontendRoot = '/opt/dist/frontend';
app.use(express.static(frontendRoot));
app.use((req, res) => res.sendFile(`${frontendRoot}/index.html`));
}

@ -1,4 +1,5 @@
import express from 'express';
import regionsService from '../services/regions.service';
export async function getRegions(req: express.Request, res: express.Response, next: express.NextFunction) {

@ -1,4 +1,5 @@
import express from 'express';
import wxService from '../services/wx.service';
export async function getRegionWx(req: express.Request, res: express.Response, next: express.NextFunction) {

@ -1,5 +1,6 @@
import fs from 'fs';
import { WxConfig } from '@shared/types/config.types';
import { WxConfig } from '@/shared/types/config.types';
export function getConfig(): WxConfig {

@ -1,5 +1,6 @@
import configService from './config.service';
import { WxConfig, WxRegion } from '@shared/types/config.types';
import { WxConfig, WxRegion } from '@/shared/types/config.types';
export function getRegions(): WxConfig['regions'] {
return configService.getConfig().regions;

@ -1,8 +1,9 @@
import axios from 'axios';
import regionsService from './regions.service';
import { WxFix } from '@shared/types/config.types';
import { WxFixData, WxData } from '@shared/types/wx.types';
import { WxFix } from '@/shared/types/config.types';
import { WxFixData, WxData } from '@/shared/types/wx.types';
const cachedData: { [key: string]: WxData } = {};

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -1,14 +1,16 @@
import 'leaflet/dist/leaflet.css';
import 'bootstrap/dist/css/bootstrap.css';
import { MapContainer, TileLayer, LayersControl, LayerGroup, Popup, Marker } from 'react-leaflet';
import { DivIcon } from 'leaflet';
import { useEffect, useState } from 'react';
import { Button, Modal, Table } from 'react-bootstrap';
import { MapContainer, TileLayer, LayersControl, LayerGroup, Popup, Marker } from 'react-leaflet';
import { useEffect, useState } from 'react';
import wxService from './services/wx.service';
import { WxRegion } from '@shared/types/config.types';
import { WxData } from '../../shared/src/types/wx.types';
import { DivIcon } from 'leaflet';
import { WxRegion } from '@/shared/types/config.types';
import { WxData } from '@/shared/types/wx.types';
function App() {
const [showModal, setShowModal] = useState(false);

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

@ -1,5 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './index.css';

@ -1,7 +1,8 @@
import { WxRegion } from '@shared/types/config.types';
import { WxData } from '@shared/types/wx.types';
import axios from 'axios';
import { WxRegion } from '@/shared/types/config.types';
import { WxData } from '@/shared/types/wx.types';
async function getRegions(): Promise<WxRegion[]> {
const response = await axios.get<WxRegion[]>('/api/regions');
return response.data;

@ -1,12 +1,20 @@
import { defineConfig } from 'vite';
import { resolve } from 'path';
import react from '@vitejs/plugin-react';
import * as path from 'path';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: [{ find: '@shared', replacement: path.resolve(__dirname, '..', 'shared', 'src') }],
root: resolve(__dirname),
build: {
lib: {
entry: resolve(__dirname, 'index.html'),
formats: ['es'],
},
minify: true,
outDir: resolve(__dirname, '..', '..', 'dist', 'frontend'),
emptyOutDir: true,
},
server: {
proxy: {
@ -18,4 +26,7 @@ export default defineConfig({
},
},
},
define: {
'process.env': `(${JSON.stringify(process.env)})`,
},
});

@ -1,12 +1,13 @@
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"baseUrl": "./src",
"module": "ES2022",
"target": "ES2022",
"lib": [
"ES2022"
"ES2022",
"DOM"
],
"sourceMap": true,
"strictNullChecks": true,
@ -17,10 +18,15 @@
"esModuleInterop": true,
"moduleResolution": "Node",
"paths": {
"@shared/*": ["../../shared/src/*"]
"@/*": ["./src/*"],
}
},
"watchOptions": {
"watchFile": "fixedpollinginterval"
}
},
"files": [],
"references": [
{ "path": "./tsconfig.node.json" },
{ "path": "./tsconfig.web.json" }
]
}

@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"include": [
"src/backend/**/*",
"src/shared/**/*",
"src/frontend/vite.config.ts"
],
"compilerOptions": {
"composite": false
}
}

@ -0,0 +1,23 @@
{
"extends": "./tsconfig.json",
"include": [
"src/frontend/**/*",
"src/shared/**/*"
],
"exclude": [
"src/frontend/vite.config.ts"
],
"compilerOptions": {
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"jsx": "react-jsx",
"composite": false,
"noEmit": true,
"allowJs": false,
"skipLibCheck": true,
"strict": true,
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true
}
}
Loading…
Cancel
Save