Browse Source

Merge remote-tracking branch 'template/master' into develop

develop
Alice Gaudon 4 months ago
parent
commit
5564bf7991
9 changed files with 34 additions and 30 deletions
  1. +2
    -0
      .gitignore
  2. +3
    -0
      app.service
  3. +1
    -1
      assets/ts/forms.ts
  4. +9
    -8
      package.json
  5. +8
    -12
      src/App.ts
  6. +3
    -3
      src/controllers/HomeController.ts
  7. +5
    -5
      src/main.ts
  8. +1
    -0
      tsconfig.frontend.json
  9. +2
    -1
      tsconfig.json

+ 2
- 0
.gitignore View File

@ -3,3 +3,5 @@ node_modules
public
dist
yarn-error.log
src/package.json

+ 3
- 0
app.service View File

@ -1,3 +1,6 @@
# Please customize values i.e. paths, user, group, WorkingDirectory based on your environment. Do not use the same
# user and group for different applications.
[Unit]
Description=Rainbox Email website
After=network-online.target


+ 1
- 1
assets/ts/forms.ts View File

@ -1,7 +1,7 @@
/*
* For labels to update their state (css selectors based on the value attribute)
*/
import {ValidationError} from "wms-core/db/Validator";
import {ValidationError} from "swaf/db/Validator";
export function updateInputs(): void {
document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>('input, textarea').forEach(el => {


+ 9
- 8
package.json View File

@ -7,21 +7,21 @@
"main": "dist/src/main.js",
"license": "AGPL-3.0-only",
"scripts": {
"dist-webpack": "webpack --mode production",
"test": "jest --verbose --runInBand",
"clean": "(test ! -d dist || rm -r dist)",
"prepareSources": "cp package.json src/",
"compile": "yarn clean && tsc",
"build": "yarn compile && yarn dist-webpack",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"dev": "concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon\" \"webpack --watch --mode development\" \"maildev\"",
"start": "yarn build && node dist/src/main.js",
"test": "jest --verbose --runInBand"
"build": "yarn prepareSources && yarn compile && webpack --mode production",
"dev": "yarn prepareSources && concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon\" \"webpack --watch --mode development\" \"maildev\"",
"start": "yarn build && node",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@fortawesome/fontawesome-free": "^5.14.0",
"@types/argon2": "^0.15.0",
"@types/config": "^0.0.36",
"@types/config": "^0.0.38",
"@types/express": "^4.17.6",
"@types/express-session": "^1.17.0",
"@types/feather-icons": "^4.7.0",
@ -48,6 +48,7 @@
"imagemin-svgo": "^8.0.0",
"img-loader": "^3.0.1",
"jest": "^26.1.0",
"maildev": "^1.1.0",
"mini-css-extract-plugin": "^1.2.1",
"node-sass": "^5.0.0",
"nodemon": "^2.0.3",
@ -64,6 +65,6 @@
"config": "^3.3.1",
"express": "^4.17.1",
"ldapjs": "^2.0.0",
"wms-core": "^0.22.0"
"swaf": "^0.23.0"
}
}

+ 8
- 12
src/App.ts View File

@ -40,7 +40,7 @@ import MailboxBackendController from "./controllers/backend/MailboxBackendContro
import RedirectBackComponent from "wms-core/components/RedirectBackComponent";
import MailAutoConfigController from "./controllers/MailAutoConfigController";
import AccountBackendController from "./controllers/backend/AccountBackendController";
import packageJson = require('../package.json');
import packageJson = require('./package.json');
export default class App extends Application {
private magicLinkWebSocketListener?: MagicLinkWebSocketListener<this>;
@ -75,12 +75,8 @@ export default class App extends Application {
}
private registerComponents() {
const redisComponent = new RedisComponent();
const mysqlComponent = new MysqlComponent();
// Base
const expressAppComponent = new ExpressAppComponent(this.addr, this.port);
this.use(expressAppComponent);
this.use(new ExpressAppComponent(this.addr, this.port));
this.use(new LogRequestsComponent());
// Static files
@ -89,21 +85,21 @@ export default class App extends Application {
// Dynamic views and routes
this.use(new NunjucksComponent());
this.use(new RedirectBackComponent());
this.use(new PreviousUrlComponent());
// Maintenance
this.use(new MaintenanceComponent(this, () => {
return redisComponent.canServe() && mysqlComponent.canServe();
return this.as(RedisComponent).canServe() && this.as(MysqlComponent).canServe();
}));
this.use(new AutoUpdateComponent());
// Services
this.use(mysqlComponent);
this.use(new MysqlComponent());
this.use(new MailComponent());
// Session
this.use(redisComponent);
this.use(new SessionComponent(redisComponent));
this.use(new RedisComponent());
this.use(new SessionComponent(this.as(RedisComponent)));
// Utils
this.use(new FormHelperComponent());
@ -120,7 +116,7 @@ export default class App extends Application {
}(this)));
// WebSocket server
this.use(new WebSocketServerComponent(this, expressAppComponent, redisComponent));
this.use(new WebSocketServerComponent(this, this.as(ExpressAppComponent), this.as(RedisComponent)));
// LDAP server
this.use(new LDAPServerComponent());


+ 3
- 3
src/controllers/HomeController.ts View File

@ -1,4 +1,4 @@
import Controller from "wms-core/Controller";
import Controller from "swaf/Controller";
import {Request, Response} from "express";
import config from "config";
@ -20,9 +20,9 @@ export default class HomeController extends Controller {
}
/**
* This is to test and assert that wms-core extended types are available
* This is to test and assert that swaf extended types are available
*/
protected async goBack(req: Request, res: Response): Promise<void> {
res.redirectBack();
res.redirect(req.getPreviousUrl() || Controller.route('home'));
}
}

+ 5
- 5
src/main.ts View File

@ -1,20 +1,20 @@
import {delimiter} from "path";
// Load config from specified path or default + wms-core/config (default defaults)
// Load config from specified path or default + swaf/config (default defaults)
process.env['NODE_CONFIG_DIR'] =
__dirname + '/../../node_modules/wms-core/config/'
__dirname + '/../node_modules/swaf/config/'
+ delimiter
+ (process.env['NODE_CONFIG_DIR'] || __dirname + '/../../config/');
import {log} from "wms-core/Logger";
import {logger} from "swaf/Logger";
import App from "./App";
import config from "config";
(async () => {
log.debug('Config path:', process.env['NODE_CONFIG_DIR']);
logger.debug('Config path:', process.env['NODE_CONFIG_DIR']);
const app = new App(config.get<string>('listen_addr'), config.get<number>('port'));
await app.start();
})().catch(err => {
log.error(err);
logger.error(err);
});

+ 1
- 0
tsconfig.frontend.json View File

@ -2,6 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "public/js",
"rootDir": "./assets",
"target": "ES6",
"strict": true,
"lib": [


+ 2
- 1
tsconfig.json View File

@ -3,6 +3,7 @@
"module": "CommonJS",
"esModuleInterop": true,
"outDir": "dist",
"rootDir": "./src",
"target": "ES6",
"strict": true,
"lib": [
@ -16,6 +17,6 @@
},
"include": [
"src/**/*",
"node_modules/wms-core/types"
"node_modules/swaf/types"
]
}

Loading…
Cancel
Save