mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
[next] Install (#1957)
* Wip * Adding Wizard and initial step <3 * Wip * Adding more steps to the Install Wizard * Mantaining state across steps * Adding Steps * Step Component * wip * feat: improved logging * feat: added tenant install route * Progress * Refactor * Adding rest install mutation * Wip * Done * Addding snapshots * URL validators * Adding validation for url, and final step * Header component and main variants * fix: resolved router * fix: corrected spec for prop * fix: updated test snapshot * Translations * Translations * Adding extra validation * prefixing events with On - onSaveData * prefixing events with On - onSaveData * Adding translations, and colors from the palette * Centering steps * Ready * feat: added production redirects * fix: fixes during production * fix: removed dead code * Placeholder translations * removing submit from cancel * Adding a description for the URL field * typo * Refactor and renaming * Using white as var * Refactor and renaming * feat: use new palette colors * fix: extracted styles * Adding await to avoid race condition with setState :) * lint * feat: added urls * fix: wizard leaking styles * fix: simplify icon style * fix: adjust global body css to remove padding to allow seamless integration * fix: types and small refactors * fix: correctly filter wizard children * refactor: simplify step containers * fix: better typecheck * test: remove obsolete snapshots * fix: don't export FormProps
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
import { isInstalled } from "talk-server/services/tenant";
|
||||
import TenantCache from "talk-server/services/tenant/cache";
|
||||
|
||||
export interface InstalledMiddlewareOptions {
|
||||
tenantCache: TenantCache;
|
||||
redirectURL?: string;
|
||||
redirectIfInstalled?: boolean;
|
||||
}
|
||||
|
||||
export const installedMiddleware = ({
|
||||
tenantCache,
|
||||
redirectIfInstalled = false,
|
||||
redirectURL = "/install",
|
||||
}: InstalledMiddlewareOptions): RequestHandler => async (req, res, next) => {
|
||||
const installed = await isInstalled(tenantCache);
|
||||
|
||||
// If Talk is installed, and redirectIfInstall is true, then it will redirect.
|
||||
// If Talk is not installed, and redirectIfInstall is false, then it will also
|
||||
// redirect.
|
||||
if (installed === redirectIfInstalled) {
|
||||
return res.redirect(redirectURL);
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NextFunction, Response } from "express";
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
import TenantCache from "talk-server/services/tenant/cache";
|
||||
import { Request } from "talk-server/types/express";
|
||||
@@ -7,10 +7,10 @@ export interface MiddlewareOptions {
|
||||
cache: TenantCache;
|
||||
}
|
||||
|
||||
export default (options: MiddlewareOptions) => async (
|
||||
export default (options: MiddlewareOptions): RequestHandler => async (
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
res,
|
||||
next
|
||||
) => {
|
||||
try {
|
||||
const { cache } = options;
|
||||
|
||||
Reference in New Issue
Block a user