Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
wajeht committed Sep 22, 2024
1 parent da9e486 commit 949023d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 42 deletions.
36 changes: 24 additions & 12 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ html,
-moz-tab-size: 4;
/* 3 */
-o-tab-size: 4;
tab-size: 4;
tab-size: 4;
/* 3 */
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-family: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol', 'Noto Color Emoji';
/* 4 */
font-feature-settings: normal;
/* 5 */
Expand Down Expand Up @@ -89,7 +90,7 @@ Add the correct text decoration in Chrome, Edge, and Safari.

abbr:where([title]) {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
text-decoration: underline dotted;
}

/*
Expand Down Expand Up @@ -135,7 +136,8 @@ code,
kbd,
samp,
pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
'Courier New', monospace;
/* 1 */
font-feature-settings: normal;
/* 2 */
Expand Down Expand Up @@ -378,7 +380,8 @@ textarea {
2. Set the default placeholder color to the user's configured gray 400 color.
*/

input::-moz-placeholder, textarea::-moz-placeholder {
input::-moz-placeholder,
textarea::-moz-placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
Expand All @@ -398,7 +401,7 @@ Set the default cursor for buttons.
*/

button,
[role="button"] {
[role='button'] {
cursor: pointer;
}

Expand Down Expand Up @@ -446,7 +449,9 @@ video {
display: none;
}

*, ::before, ::after {
*,
::before,
::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
Expand Down Expand Up @@ -735,12 +740,14 @@ video {
}

.transform {
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)) !important;
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate))
skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x))
scaleY(var(--tw-scale-y)) !important;
}

@keyframes pulse {
50% {
opacity: .5;
opacity: 0.5;
}
}

Expand Down Expand Up @@ -1071,8 +1078,13 @@ video {

.backdrop-blur-sm {
--tw-backdrop-blur: blur(4px) !important;
-webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia) !important;
backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia) !important;
-webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness)
var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate)
var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate)
var(--tw-backdrop-sepia) !important;
backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast)
var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert)
var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia) !important;
}

* {
Expand Down Expand Up @@ -1135,7 +1147,7 @@ html {
}

.hover\:outline-\[\#1A8755\]:hover {
outline-color: #1A8755 !important;
outline-color: #1a8755 !important;
}

.hover\:outline-slate-50:hover {
Expand Down
24 changes: 12 additions & 12 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export const appConfig = {
api_url: process.env.API_URL as unknown as string,
base_url: process.env.BASE_URL as unknown as string,
env: process.env.ENV as 'production' | 'development' | 'testing' | 'local',
domain: process.env.DOMAIN,
jwt_secret: process.env.JWT_SECRET,
password_salt: process.env.PASSWORD_SALT,
admin_email: process.env.ADMIN_EMAIL,
admin_name: process.env.ADMIN_NAME,
x_api_key: process.env.X_API_KEY,
domain: process.env.DOMAIN as unknown as string,
jwt_secret: process.env.JWT_SECRET as unknown as string,
password_salt: process.env.PASSWORD_SALT as unknown as string,
admin_email: process.env.ADMIN_EMAIL as unknown as string,
admin_name: process.env.ADMIN_NAME as unknown as string,
x_api_key: process.env.X_API_KEY as unknown as string,
} as const;

export const databaseConfig = {
Expand All @@ -27,11 +27,11 @@ export const sessionConfig = {
} as const;

export const emailConfig = {
host: process.env.EMAIL_HOST,
port: process.env.EMAIL_PORT,
secure: process.env.EMAIL_SECURE,
auth_email: process.env.EMAIL_AUTH_EMAIL,
auth_pass: process.env.EMAIL_AUTH_PASS,
host: process.env.EMAIL_HOST as unknown as string,
port: process.env.EMAIL_PORT as unknown as string,
secure: process.env.EMAIL_SECURE as unknown as string,
auth_email: process.env.EMAIL_AUTH_EMAIL as unknown as string,
auth_pass: process.env.EMAIL_AUTH_PASS as unknown as string,
} as const;

export const redisConfig = {
Expand All @@ -53,7 +53,7 @@ export const oauthConfig = {
client_secret: process.env.GOOGLE_CLIENT_SECRET as unknown as string,
oauth_redirect_url: process.env.GOOGLE_OAUTH_REDIRECT_URL as unknown as string,
},
GITHUB: {
github: {
client_id: process.env.GITHUB_CLIENT_ID as unknown as string,
client_secret: process.env.GITHUB_CLIENT_SECRET as unknown as string,
oauth_redirect_url: process.env.GITHUB_OAUTH_REDIRECT_URL as unknown as string,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/crons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function removeCaches() {
// @ts-ignore
redis.keys('*', function (err, keys) {
if (err) return null;
// @ts-ignore
// @ts-ignore
keys.forEach((key: any) => {
if (key.match(/close-powerlifting.+/g)) {
logger.info(`deleted redis cache ${key}!`);
Expand Down
14 changes: 7 additions & 7 deletions src/views/views.controllers.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { StatusCodes } from 'http-status-codes';
import { beforeEach, describe, expect, test, vi } from 'vitest';
import { beforeEach, describe, expect, Mock, test, vi } from 'vitest';

import { getRankings } from '../api/rankings/rankings.services';
import { EMAIL } from '../config/constants';
import { emailConfig } from '../config/constants';
import { getHostName, hashKey } from '../utils/helpers';
import mail from '../utils/mail';
import {
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('getHomePage', () => {
render: vi.fn(),
} as any;

getRankings.mockResolvedValueOnce([]);
(getRankings as Mock).mockResolvedValueOnce([]);

await getHomePage(req, res);

Expand Down Expand Up @@ -119,11 +119,11 @@ describe('postRegisterPage', () => {
redirect: vi.fn(),
} as any;

User.findOne.mockResolvedValueOnce({
(User.findOne as Mock).mockResolvedValueOnce({
id: 1,
});

User.create.mockResolvedValueOnce({
(User.create as Mock).mockResolvedValueOnce({
id: 1,
});

Expand Down Expand Up @@ -244,7 +244,7 @@ describe('getVerifyEmailPage', () => {
redirect: vi.fn(),
} as any;

User.findOne.mockResolvedValueOnce({ id: 1 });
(User.findOne as Mock).mockResolvedValueOnce({ id: 1 });

await getVerifyEmailPage(req, res);

Expand Down Expand Up @@ -340,7 +340,7 @@ describe('getVerifyEmailPage', () => {
verification_token: 'token',
});

sendWelcomeEmail.mockResolvedValueOnce({
(sendWelcomeEmail as Mock).mockResolvedValueOnce({
// userId: 1,
email: 'email',
name: 'name',
Expand Down
6 changes: 3 additions & 3 deletions src/views/views.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StatusCodes } from 'http-status-codes';
import mongoose from 'mongoose';

import { getRankings } from '../api/rankings/rankings.services';
import { EMAIL } from '../config/constants';
import { emailConfig } from '../config/constants';
import { isCronServiceStarted } from '../utils/crons';
import { getHostName, hashKey } from '../utils/helpers';
import logger from '../utils/logger';
Expand Down Expand Up @@ -148,8 +148,8 @@ export async function postContactPage(req: Request, res: Response) {
const { name, email, message } = req.body;

mail.sendMail({
from: `"Close Powerlifting" <${EMAIL.AUTH_EMAIL}>`,
to: EMAIL.AUTH_EMAIL,
from: `"Close Powerlifting" <${emailConfig.auth_email}>`,
to: emailConfig.auth_email,
subject: `Contact Request from ${email}`,
html: contactHTML({ name, email, message }),
});
Expand Down
14 changes: 7 additions & 7 deletions src/views/views.services.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @ts-expect-error - it's ok
import { faker } from '@faker-js/faker';
import bcrypt from 'bcryptjs';

import { EMAIL, PASSWORD_SALT } from '../config/constants';
import { emailConfig, appConfig } from '../config/constants';
import { generateAPIKey } from '../utils/helpers';
import logger from '../utils/logger';
import mail from '../utils/mail';
import redis from '../utils/redis';
import adminNewAPIKeyHTML from '../utils/templates/admin-new-api-key';
import newAPIKeyHTML from '../utils/templates/new-api-key';
import verifyEmailHTML from '../utils/templates/verify-email';
Expand Down Expand Up @@ -37,7 +37,7 @@ export async function resetAPIKey(userParams: UserParams): Promise<void> {
const verified = await updateUser(email, { key: hashedKey });

mail.sendMail({
from: `"Close Powerlifting" <${EMAIL.AUTH_EMAIL}>`,
from: `"Close Powerlifting" <${emailConfig.auth_email}>`,
to: email,
subject: 'New API key for Close Powerlifting',
html: newAPIKeyHTML({ name: verified!.name!, key: unhashedKey }),
Expand All @@ -49,7 +49,7 @@ export async function resetAPIKey(userParams: UserParams): Promise<void> {
export async function resetAdminAPIKey(userParams: UserParams): Promise<void> {
const { name, email } = userParams;
const password = faker.internet.password(50);
const hashedPassword = await bcrypt.hash(password, parseInt(PASSWORD_SALT!));
const hashedPassword = await bcrypt.hash(password, parseInt(appConfig.password_salt));

const { unhashedKey, hashedKey } = await generateAPIKey({ ...userParams, admin: true });

Expand All @@ -59,7 +59,7 @@ export async function resetAdminAPIKey(userParams: UserParams): Promise<void> {
});

mail.sendMail({
from: `"Close Powerlifting" <${EMAIL.AUTH_EMAIL}>`,
from: `"Close Powerlifting" <${emailConfig.auth_email}>`,
to: email,
subject: 'New API Key and Admin Password for Close Powerlifting',
html: adminNewAPIKeyHTML({ name, password, apiKey: unhashedKey }),
Expand All @@ -76,7 +76,7 @@ export async function sendVerificationEmail({
userId,
}: VerificationEmailPrams) {
await mail.sendMail({
from: `"Close Powerlifting" <${EMAIL.AUTH_EMAIL}>`,
from: `"Close Powerlifting" <${emailConfig.auth_email}>`,
to: email,
subject: 'Account verification',
html: verifyEmailHTML({
Expand All @@ -101,7 +101,7 @@ export async function sendWelcomeEmail(userParams: UserParams) {
});

mail.sendMail({
from: `"Close Powerlifting" <${EMAIL.AUTH_EMAIL}>`,
from: `"Close Powerlifting" <${emailConfig.auth_email}>`,
to: email,
subject: 'API Key for Close Powerlifting',
html: welcomeHTML({ name: verified!.name!, key: unhashedKey }),
Expand Down

0 comments on commit 949023d

Please sign in to comment.