Skip to content

Commit

Permalink
App store preparations
Browse files Browse the repository at this point in the history
- Updated icons, index.html, and manifest to prepare for TWA
- Implemented Docker fix to get around prisma issue prisma/prisma#16553
- Added logs to hopefully detect issue with log in
  • Loading branch information
MattHalloran committed Jan 8, 2023
1 parent 7129292 commit a104b81
Show file tree
Hide file tree
Showing 28 changed files with 296 additions and 19 deletions.
7 changes: 4 additions & 3 deletions packages/server/Dockerfile
@@ -1,5 +1,6 @@
# Stage 0. Copy required files
FROM node:16-alpine as stage0
# NOTE: Using alpine3.16 because of this issue: https://github.com/prisma/prisma/issues/16553
FROM node:16-alpine3.16 as stage0

# Set working directory
ARG PROJECT_DIR
Expand Down Expand Up @@ -27,7 +28,7 @@ COPY --chown=node:node scripts/* scripts/
RUN chown -R node:node .

# Stage 1. Copy files from stage 0, and install yarn packages
FROM node:16-alpine as stage1
FROM node:16-alpine3.16 as stage1

# Set working directory
ARG PROJECT_DIR
Expand All @@ -43,7 +44,7 @@ RUN yarn install
RUN yarn global add typescript ts-node nodemon prisma@4.0.0

# Stage 2. Copy files from stage 1, and install required unix tools
FROM node:16-alpine as stage2
FROM node:16-alpine3.16 as stage2

# Set working directory
ARG PROJECT_DIR
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/error.ts
@@ -1,5 +1,5 @@
import { ApolloError } from 'apollo-server-express';
import { genErrorCode, logger, LogLevel } from './logger';
import { logger, LogLevel } from './logger';

export class CustomError extends ApolloError {
constructor(error: any, message?: any, logMeta?: { [key: string]: any }) {
Expand All @@ -15,7 +15,7 @@ export async function validateArgs(schema: any, args: any) {
try {
await schema.validate(args, { abortEarly: false });
} catch (err: any) {
console.info('Invalid arguments')
logger.log(LogLevel.info, 'Failed to validate args', args);
throw new CustomError({
code: 'ARGS_VALIDATION_FAILED',
message: err.errors
Expand Down
12 changes: 11 additions & 1 deletion packages/server/src/schema/customer.ts
Expand Up @@ -12,6 +12,7 @@ import { IWrap, RecursivePartial } from '../types';
import { Context } from '../context';
import { GraphQLResolveInfo } from 'graphql';
import { AccountStatus, AddCustomerRoleInput, ChangeCustomerStatusInput, Count, Customer, CustomerInput, DeleteCustomerInput, LoginInput, RemoveCustomerRoleInput, RequestPasswordChangeInput, ResetPasswordInput, SignUpInput, UpdateCustomerInput } from './types';
import { logger, LogLevel } from '../logger';

const LOGIN_ATTEMPTS_TO_SOFT_LOCKOUT = 3;
const SOFT_LOCKOUT_DURATION = 15 * 60 * 1000;
Expand Down Expand Up @@ -152,7 +153,9 @@ export const resolvers = {
},
Mutation: {
login: async (_parent: undefined, { input }: IWrap<LoginInput>, { prisma, req, res }: Context, info: GraphQLResolveInfo): Promise<RecursivePartial<Customer>> => {
logger.log(LogLevel.info, 'Logging in user a...', input);
const prismaInfo = getCustomerSelect(info);
logger.log(LogLevel.info, 'Logging in user b...');
// If username and password wasn't passed, then use the session cookie data to validate
if (!input.email || !input.password) {
if (req.customerId && req.roles && req.roles.length > 0) {
Expand All @@ -164,6 +167,7 @@ export const resolvers = {
}
res.clearCookie(COOKIE.Jwt);
}
logger.log(LogLevel.info, 'Logging in user failed c...');
throw new CustomError(CODE.BadCredentials);
}
// Validate input format
Expand All @@ -182,6 +186,7 @@ export const resolvers = {
})
// Send new verification email
sendResetPasswordLink(input.email, customer.id, requestCode);
logger.log(LogLevel.info, 'Logging in user failed d...');
throw new CustomError(CODE.MustResetPassword);
}
// Validate verification code, if supplied
Expand All @@ -205,7 +210,10 @@ export const resolvers = {
[AccountStatus.SoftLock]: CODE.SoftLockout,
[AccountStatus.HardLock]: CODE.HardLockout
}
if (customer.status in status_to_code) throw new CustomError((status_to_code as any)[customer.status]);
if (customer.status in status_to_code) {
logger.log(LogLevel.info, 'Logging in user failed e...', customer.status);
throw new CustomError((status_to_code as any)[customer.status]);
}
// Now we can validate the password
const validPassword = customer.password && bcrypt.compareSync(input.password, customer.password);
if (validPassword) {
Expand All @@ -224,6 +232,7 @@ export const resolvers = {
const cart = await getCart(prisma, info, customer.id);
const userData: any = await prisma.customer.findUnique({ where: { id: customer.id }, ...prismaInfo });
if (cart) userData.cart = cart;
logger.log(LogLevel.info, 'Logging in user returning data...', userData);
return userData;
} else {
let new_status = AccountStatus.Unlocked;
Expand All @@ -237,6 +246,7 @@ export const resolvers = {
where: { id: customer.id },
data: { status: new_status, loginAttempts: login_attempts, lastLoginAttempt: new Date().toISOString() }
})
logger.log(LogLevel.info, 'Logging in user failed f...');
throw new CustomError(CODE.BadCredentials);
}
},
Expand Down
Binary file added packages/ui/public/android-chrome-192x192.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\matth\Downloads\favicon_package_v0.16 (3).zip
Binary file added packages/ui/public/android-chrome-512x512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\matth\Downloads\favicon_package_v0.16 (3).zip
Binary file modified packages/ui/public/apple-touch-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/ui/public/apple-touch-icon.pngZone.Identifier
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\matth\Downloads\favicon_package_v0.16 (3).zip
9 changes: 9 additions & 0 deletions packages/ui/public/browserconfig.xml
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
3 changes: 3 additions & 0 deletions packages/ui/public/browserconfig.xmlZone.Identifier
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\matth\Downloads\favicon_package_v0.16 (3).zip
Binary file added packages/ui/public/favicon-16x16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/ui/public/favicon-16x16.pngZone.Identifier
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\matth\Downloads\favicon_package_v0.16 (3).zip
Binary file added packages/ui/public/favicon-32x32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/ui/public/favicon-32x32.pngZone.Identifier
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\matth\Downloads\favicon_package_v0.16 (3).zip
Binary file removed packages/ui/public/favicon-android.png
Binary file not shown.
4 changes: 0 additions & 4 deletions packages/ui/public/favicon-android.pngZone.Identifier

This file was deleted.

Binary file removed packages/ui/public/favicon-android.xcf
Binary file not shown.
Binary file added packages/ui/public/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions packages/ui/public/favicon.icoZone.Identifier
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\matth\Downloads\favicon_package_v0.16 (3).zip
Binary file removed packages/ui/public/favicon.xcf
Binary file not shown.
32 changes: 23 additions & 9 deletions packages/ui/public/index.html
Expand Up @@ -5,16 +5,29 @@
<meta charset="utf-8" />
<link type="text/plain" rel="author" href="https://www.newlifenurseryinc.com/humans.txt" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>New Life Nursery</title>
<meta name="description"
content="New Life Nursery is a wholesale plant distributor, located in Southern New Jersey. We strive to provide beautiful, healthy plants at competitive prices." />
<!-- Start Favicons -->
<link rel="icon" href="%PUBLIC_URL%/favicon.png">
<link rel="apple-touch-icon" href="%PUBLIC_URL%/apple-touch-icon.png" />
<link rel="mask-icon" href="%PUBLIC_URL%/mask-icon.svg" color="#2C882C">
<!-- End Favicons -->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>New Life Nursery</title>
<!-- Theme colors -->
<meta name="theme-color" content="#002784">
<meta name="msapplication-TileColor" media="(prefers-color-scheme: light)" content="#003300">
<meta name="msapplication-TileColor" media="(prefers-color-scheme: dark)" content="#242930">
<!-- PWA info -->
<meta name="apple-touch-fullscreen" content="yes" />
<meta name="apple-mobile-web-app-title" content="New Life Nursery" />
<meta name="apple-mobile-web-app-status-bar-style" content="#002784" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<!-- Webmanifests -->
<!-- <link rel="manifest" href="/manifest.light.json" media="(prefers-color-scheme: no-preference), (prefers-color-scheme: light)" />
<link rel="manifest" href="/manifest.dark.json" media="(prefers-color-scheme: dark)" /> -->
<link rel="manifest" href="/manifest.json" />
<!-- Favicons -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<!-- Start Google Fonts -->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Kite+One&display=swap" rel="stylesheet">
Expand All @@ -24,7 +37,8 @@
<meta property="og:type" content="website">
<meta property="og:site_name" content="New Life Nursery Inc.">
<meta property="og:title" content="Welcome to New Life Nursery!">
<meta property="og:description" content="New Life Nursery is a wholesale plant distributor, located in Southern New Jersey. We strive to provide beautiful, healthy plants at competitive prices.">
<meta property="og:description"
content="New Life Nursery is a wholesale plant distributor, located in Southern New Jersey. We strive to provide beautiful, healthy plants at competitive prices.">
<meta property="og:url" content="https://www.newlifenurseryinc.com/">
<meta property="og:image" content="https://www.newlifenurseryinc.com/favicon.png">
<meta property="og:image:width" content="500">
Expand Down
Binary file added packages/ui/public/mstile-150x150.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/ui/public/mstile-150x150.pngZone.Identifier
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\matth\Downloads\favicon_package_v0.16 (3).zip

0 comments on commit a104b81

Please sign in to comment.