Merge remote-tracking branch 'boilerplate/master' into develop
This commit is contained in:
commit
f5ccab3b34
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,4 +5,6 @@ dist
|
|||||||
yarn-error.log
|
yarn-error.log
|
||||||
storage/tmp
|
storage/tmp
|
||||||
storage/uploads
|
storage/uploads
|
||||||
|
|
||||||
config/local.*
|
config/local.*
|
||||||
|
src/package.json
|
||||||
|
@ -129,6 +129,15 @@ body > header {
|
|||||||
.feather {
|
.feather {
|
||||||
--icon-size: 24px;
|
--icon-size: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.tip {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity ease-out 100ms;
|
||||||
|
transition-delay: 150ms;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
18
package.json
18
package.json
@ -5,22 +5,22 @@
|
|||||||
"repository": "https://eternae.ink/arisu/ily.li",
|
"repository": "https://eternae.ink/arisu/ily.li",
|
||||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
"author": "Alice Gaudon <alice@gaudon.pro>",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"main": "dist/src/main.js",
|
"main": "dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dist-webpack": "webpack --mode production",
|
"test": "jest --verbose --runInBand",
|
||||||
"clean": "(test ! -d dist || rm -r dist)",
|
"clean": "(test ! -d dist || rm -r dist)",
|
||||||
|
"prepareSources": "cp package.json src/",
|
||||||
"compile": "yarn clean && tsc",
|
"compile": "yarn clean && tsc",
|
||||||
"build": "yarn compile && yarn dist-webpack",
|
"build": "yarn prepareSources && yarn compile && webpack --mode production",
|
||||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
"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\"",
|
||||||
"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",
|
||||||
"start": "yarn build && node dist/src/main.js",
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
|
||||||
"test": "jest --verbose --runInBand"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.9.0",
|
"@babel/core": "^7.9.0",
|
||||||
"@babel/preset-env": "^7.9.5",
|
"@babel/preset-env": "^7.9.5",
|
||||||
"@fortawesome/fontawesome-free": "^5.14.0",
|
"@fortawesome/fontawesome-free": "^5.14.0",
|
||||||
"@types/config": "^0.0.36",
|
"@types/config": "^0.0.38",
|
||||||
"@types/express": "^4.17.6",
|
"@types/express": "^4.17.6",
|
||||||
"@types/express-session": "^1.17.0",
|
"@types/express-session": "^1.17.0",
|
||||||
"@types/feather-icons": "^4.7.0",
|
"@types/feather-icons": "^4.7.0",
|
||||||
@ -62,6 +62,6 @@
|
|||||||
"config": "^3.3.1",
|
"config": "^3.3.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"formidable": "^1.2.2",
|
"formidable": "^1.2.2",
|
||||||
"swaf": "^0.22.5"
|
"swaf": "^0.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
src/App.ts
23
src/App.ts
@ -40,9 +40,7 @@ import BackendController from "swaf/helpers/BackendController";
|
|||||||
import RedirectBackComponent from "swaf/components/RedirectBackComponent";
|
import RedirectBackComponent from "swaf/components/RedirectBackComponent";
|
||||||
import DummyMigration from "swaf/migrations/DummyMigration";
|
import DummyMigration from "swaf/migrations/DummyMigration";
|
||||||
import DropLegacyLogsTable from "swaf/migrations/DropLegacyLogsTable";
|
import DropLegacyLogsTable from "swaf/migrations/DropLegacyLogsTable";
|
||||||
import {Session} from "express-session";
|
import packageJson = require('./package.json');
|
||||||
import packageJson = require('../package.json');
|
|
||||||
import FixUserMainEmailRelation from "swaf/auth/migrations/FixUserMainEmailRelation";
|
|
||||||
|
|
||||||
export default class App extends Application {
|
export default class App extends Application {
|
||||||
public constructor(
|
public constructor(
|
||||||
@ -75,13 +73,8 @@ export default class App extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private registerComponents() {
|
private registerComponents() {
|
||||||
const redisComponent = new RedisComponent();
|
|
||||||
const mysqlComponent = new MysqlComponent();
|
|
||||||
|
|
||||||
const expressAppComponent = new ExpressAppComponent(this.addr, this.port);
|
|
||||||
this.use(expressAppComponent);
|
|
||||||
|
|
||||||
// Base
|
// Base
|
||||||
|
this.use(new ExpressAppComponent(this.addr, this.port));
|
||||||
this.use(new LogRequestsComponent());
|
this.use(new LogRequestsComponent());
|
||||||
|
|
||||||
// Static files
|
// Static files
|
||||||
@ -90,21 +83,21 @@ export default class App extends Application {
|
|||||||
|
|
||||||
// Dynamic views and routes
|
// Dynamic views and routes
|
||||||
this.use(new NunjucksComponent());
|
this.use(new NunjucksComponent());
|
||||||
this.use(new RedirectBackComponent());
|
this.use(new PreviousUrlComponent());
|
||||||
|
|
||||||
// Maintenance
|
// Maintenance
|
||||||
this.use(new MaintenanceComponent(this, () => {
|
this.use(new MaintenanceComponent(this, () => {
|
||||||
return redisComponent.canServe() && mysqlComponent.canServe();
|
return this.as(RedisComponent).canServe() && this.as(MysqlComponent).canServe();
|
||||||
}));
|
}));
|
||||||
this.use(new AutoUpdateComponent());
|
this.use(new AutoUpdateComponent());
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
this.use(mysqlComponent);
|
this.use(new MysqlComponent());
|
||||||
this.use(new MailComponent());
|
this.use(new MailComponent());
|
||||||
|
|
||||||
// Session
|
// Session
|
||||||
this.use(redisComponent);
|
this.use(new RedisComponent());
|
||||||
this.use(new SessionComponent(redisComponent));
|
this.use(new SessionComponent(this.as(RedisComponent)));
|
||||||
this.use(new AuthComponent(new class extends AuthGuard<MagicLink | AuthToken> {
|
this.use(new AuthComponent(new class extends AuthGuard<MagicLink | AuthToken> {
|
||||||
public async getProofForSession(session: Session): Promise<MagicLink | AuthToken | null> {
|
public async getProofForSession(session: Session): Promise<MagicLink | AuthToken | null> {
|
||||||
return await MagicLink.bySessionId(
|
return await MagicLink.bySessionId(
|
||||||
@ -135,7 +128,7 @@ export default class App extends Application {
|
|||||||
this.use(new CsrfProtectionComponent());
|
this.use(new CsrfProtectionComponent());
|
||||||
|
|
||||||
// WebSocket server
|
// WebSocket server
|
||||||
this.use(new WebSocketServerComponent(this, expressAppComponent, redisComponent));
|
this.use(new WebSocketServerComponent(this, this.as(ExpressAppComponent), this.as(RedisComponent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerWebSocketListeners() {
|
private registerWebSocketListeners() {
|
||||||
|
@ -20,6 +20,6 @@ export default class HomeController extends Controller {
|
|||||||
* This is to test and assert that swaf 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> {
|
protected async goBack(req: Request, res: Response): Promise<void> {
|
||||||
res.redirectBack();
|
res.redirect(req.getPreviousUrl() || Controller.route('home'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/main.ts
10
src/main.ts
@ -2,19 +2,19 @@ import {delimiter} from "path";
|
|||||||
|
|
||||||
// Load config from specified path or default + swaf/config (default defaults)
|
// Load config from specified path or default + swaf/config (default defaults)
|
||||||
process.env['NODE_CONFIG_DIR'] =
|
process.env['NODE_CONFIG_DIR'] =
|
||||||
__dirname + '/../../node_modules/swaf/config/'
|
__dirname + '/../node_modules/swaf/config/'
|
||||||
+ delimiter
|
+ delimiter
|
||||||
+ (process.env['NODE_CONFIG_DIR'] || __dirname + '/../../config/');
|
+ (process.env['NODE_CONFIG_DIR'] || __dirname + '/../config/');
|
||||||
|
|
||||||
import {log} from "swaf/Logger";
|
import {logger} from "swaf/Logger";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import config from "config";
|
import config from "config";
|
||||||
|
|
||||||
(async () => {
|
(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'));
|
const app = new App(config.get<string>('listen_addr'), config.get<number>('port'));
|
||||||
await app.start();
|
await app.start();
|
||||||
})().catch(err => {
|
})().catch(err => {
|
||||||
log.error(err);
|
logger.error(err);
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"extends": "./tsconfig.json",
|
"extends": "./tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "public/js",
|
"outDir": "public/js",
|
||||||
|
"rootDir": "./assets",
|
||||||
"target": "ES6",
|
"target": "ES6",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"lib": [
|
"lib": [
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"module": "CommonJS",
|
"module": "CommonJS",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
|
"rootDir": "./src",
|
||||||
"target": "ES6",
|
"target": "ES6",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"lib": [
|
"lib": [
|
||||||
|
Loading…
Reference in New Issue
Block a user