Skip to content

Commit 8ac890e

Browse files
authored
feat: welcomeText (#562)
* feat: welcomeText * clean default text block
1 parent 0808364 commit 8ac890e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+329
-64
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { config } from 'config';
2+
import i18n from 'i18next';
3+
import { Link, Text } from 'jsx-email';
4+
import { AppLogo } from './app-logo';
5+
6+
const link = {
7+
color: '#0366d6',
8+
fontSize: '.75rem',
9+
lineHeight: '1.13rem',
10+
};
11+
12+
export const EmailReplyTo = ({ email, emailText }: { email?: string; emailText?: string }) => (
13+
<>
14+
<AppLogo />
15+
<Text
16+
style={{ marginTop: '1.25rem', gap: '0.25rem', textAlign: 'center' as const, alignItems: 'center', display: 'flex', justifyContent: 'center' }}
17+
>
18+
{email && (
19+
<Link style={link} href={`mailto:${email}`}>
20+
{emailText ? emailText : i18n.t('backend:email.inviter_email')}
21+
</Link>
22+
)}
23+
24+
<Link style={link} href={`mailto:${config.supportEmail}`}>
25+
{i18n.t('backend:email.support_email')}
26+
</Link>
27+
{!email && '・'}
28+
</Text>
29+
</>
30+
);

backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"quick": "cross-env PGLITE=true tsx scripts/quick.ts && cross-env PGLITE=true pnpm dev",
1010
"start": "cross-env NODE_ENV=production tsx dist/index.js",
1111
"dev": "cross-env NODE_ENV=development tsx --watch-path=src src/index.ts",
12+
"tunnel": "cross-env NODE_ENV=tunnel tsx --watch-path=src src/index.ts",
1213
"check": "tsc --pretty",
1314
"check:beta": "tsgo --pretty",
1415
"tsperf": "rm -rf dist && tsc --extendedDiagnostics",

backend/src/env.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export const env = createEnv({
1818
.string()
1919
.optional()
2020
.transform((v) => v === 'true'),
21-
DATABASE_URL: z.string().url(),
22-
NODE_ENV: z.union([z.literal('development'), z.literal('production'), z.literal('test')]),
21+
DATABASE_URL: z.url(),
22+
NODE_ENV: z.union([z.literal('development'), z.literal('production'), z.literal('staging'), z.literal('tunnel')]),
2323
PORT: z.string().optional(),
2424
UNSUBSCRIBE_SECRET: z.string(),
2525

@@ -60,6 +60,8 @@ export const env = createEnv({
6060
S3_ACCESS_KEY_SECRET: z.string().default(''),
6161

6262
TRIGGER_SECRET_KEY: z.string().optional(),
63+
64+
WEBHOOK_SECRET: z.string().optional(),
6365
},
6466
runtimeEnv: process.env,
6567
emptyStringAsUndefined: true,

backend/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { env } from './env';
1616

1717
// import { sdk } from './tracing';
1818

19-
const startTunnel = config.mode === 'development' ? (await import('#/lib/start-tunnel')).default : () => null;
19+
const startTunnel = config.mode === 'tunnel' ? (await import('#/lib/start-tunnel')).default : () => null;
2020

2121
const isPGliteDatabase = (_db: unknown): _db is PgliteDatabase => !!env.PGLITE;
2222

backend/src/modules/auth/handlers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,12 @@ const authRouteHandlers = app
590590
.openapi(authRoutes.githubSignInCallback, async (ctx) => {
591591
const { code, state, error } = ctx.req.valid('query');
592592

593+
// Handle redirect flow for custom app use (e.g not auth)
594+
try {
595+
const parsedState = JSON.parse(atob(state));
596+
if (parsedState.redirectUrl) return ctx.redirect(`${parsedState.redirectUrl}?code=${code}&state=${state}&error=${error}`, 302);
597+
} catch (_) {} // silently ignore (standard OAuth state)
598+
593599
// redirect if there is no code or error in callback
594600
if (error || !code) throw new ApiError({ status: 400, type: 'oauth_failed', severity: 'warn', redirectToFrontend: true });
595601

backend/src/modules/auth/helpers/cookie.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type CookieName =
2828
export const setAuthCookie = async (ctx: Context, name: CookieName, content: string, timeSpan: TimeSpan) => {
2929
const versionedName = `${config.slug}-${name}-${config.cookieVersion}`;
3030
const options = {
31-
secure: isProduction,
31+
secure: config.mode !== 'development',
3232
path: '/',
3333
domain: isProduction ? config.domain : undefined,
3434
httpOnly: true,

backend/src/modules/organizations/handlers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { defaultHook } from '#/utils/default-hook';
2222
import { getIsoDate } from '#/utils/iso-date';
2323
import { getOrderColumn } from '#/utils/order-column';
2424
import { prepareStringForILikeFilter } from '#/utils/sql';
25+
import { defaultWelcomeText } from '#json/text-blocks.json';
2526

2627
const app = new OpenAPIHono<Env>({ defaultHook });
2728

@@ -51,6 +52,7 @@ const organizationRouteHandlers = app
5152
shortName: name,
5253
slug,
5354
languages: [config.defaultLanguage],
55+
welcomeText: defaultWelcomeText,
5456
defaultLanguage: config.defaultLanguage,
5557
createdBy: user.id,
5658
})

backend/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"baseUrl": ".",
2020

2121
"paths": {
22-
"#/*": ["./src/*"]
22+
"#/*": ["./src/*"],
23+
"#json/*": ["../json/*"],
2324
}
2425
},
2526
"include": ["src/**/*", "drizzle.config.ts", "emails", "scripts", "trigger.config.ts", "../config/*"],

cella.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export const config = {
7373
'backend/src/permissions/permissions-config.ts',
7474
'backend/src/lib/docs-config.ts',
7575
'backend/src/lib/notifications/novu-config.ts',
76+
'json/text-blocks.json',
7677
'locales/en/about.json',
7778
'locales/en/app.json',
7879
],

config/staging.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export default {
66
debug: false,
77

88
domain: 'cella.dev',
9-
frontendUrl: 'https://cella.dev',
10-
backendUrl: 'https://api.cella.dev',
11-
backendAuthUrl: 'https://api.cella.dev/auth',
12-
electricUrl: 'https://electric.cella.dev',
9+
frontendUrl: 'https://staging.cella.dev',
10+
backendUrl: 'https://api-staging.cella.dev',
11+
backendAuthUrl: 'https://api-staging.cella.dev/auth',
12+
electricUrl: 'https://electric-staging.cella.dev',
1313

1414
// Hide chat widget in staging
1515
gleapToken: undefined,

0 commit comments

Comments
 (0)