Skip to content

Commit

Permalink
Merge pull request #131 from complexdatacollective/next
Browse files Browse the repository at this point in the history
Beta 5
  • Loading branch information
buckhalt authored Jun 3, 2024
2 parents 5efbb32 + 49e5684 commit 632e710
Show file tree
Hide file tree
Showing 614 changed files with 13,680 additions and 31,204 deletions.
61 changes: 22 additions & 39 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,39 +1,22 @@
# Since the ".env" file is gitignored, you can use the ".env.example" file to
# build a new ".env" file when you clone the repo. Keep this file up-to-date
# when you add new variables to `.env`.

# This file will be committed to version control, so make sure not to have any
# secrets in it. If you are cloning this repo, create a copy of this file named
# ".env" and populate it with your secrets.

# When adding additional environment variables, the schema in "/src/env.mjs"
# should be updated accordingly.

# Vercel Postgres
POSTGRES_URL="************"
POSTGRES_PRISMA_URL="************"
POSTGRES_URL_NO_SSL="************"
POSTGRES_URL_NON_POOLING="************"
POSTGRES_USER="************"
POSTGRES_HOST="************"
POSTGRES_PASSWORD="************"
POSTGRES_DATABASE="************"

NEXT_PUBLIC_URL="http://localhost:3000"


# Uploadthing
UPLOADTHING_SECRET=""
UPLOADTHING_APP_ID=""


# optional global override for analytics
# can be used to diable analytics in development
#NEXT_PUBLIC_DISABLE_ANALYTICS=true

# optional manual specification for installation ID. Useful in scenarios such as
# CI/CD where the installation ID cannot be automatically determined because
# there is no database. Also useful for ensuring consistent ID between DB
# resets.
#INSTALLATION_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

# -------------------
# Optional environment variables - uncomment to use
# -------------------

#SANDBOX_MODE=false # true or false - if true, the app will use the sandbox mode, which disables resetting the database and other features
#PUBLIC_URL="http://yourdomain.com" # When using advanced deployment, this is required. Set to the domain name of your app
#DISABLE_ANALYTICS=true # true or false - if true, the app will not send anonymous analytics data to the server
#INSTALLATION_ID="your-app-name" # A unique identifier for your app, used for analytics. Generated automatically if not set.

# -------------------
# Required environment variables
# -------------------

UPLOADTHING_SECRET=sk_live_xxxxxx # Your UploadThing secret key
UPLOADTHING_APP_ID=xxxxxxx # Your UploadThing app ID

POSTGRES_USER="postgres" # Your PostgreSQL username
POSTGRES_PASSWORD="postgres" # Your PostgreSQL password
POSTGRES_DATABASE="postgres" # Your PostgreSQL database name
POSTGRES_HOST="postgres" # Your PostgreSQL host
POSTGRES_PRISMA_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DATABASE}?schema=public" # A pooled connection URL for Prisma.
POSTGRES_URL_NON_POOLING="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DATABASE}?schema=public" # A non-pooling connection URL for Prisma
9 changes: 4 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');

/** @type {import("eslint").Linter.Config} */
Expand All @@ -19,15 +18,15 @@ const config = {
parserOptions: {
project: path.join(__dirname, 'tsconfig.json'),
},
plugins: ['@typescript-eslint', 'eslint-plugin-local-rules'],
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:@typescript-eslint/recommended',
'next/core-web-vitals',
'prettier',
],
ignorePatterns: ['node_modules', '*.stories.*', '*.test.*'],
ignorePatterns: ['node_modules', '*.stories.*', '*.test.*', 'public', '.eslintrc.cjs',],
rules: {
"@next/next/no-img-element": "off",
"import/no-anonymous-default-export": "off",
Expand All @@ -42,7 +41,7 @@ const config = {
},
],
'@typescript-eslint/no-unused-vars': [
'warn',
'error',
{
argsIgnorePattern: '^_',
},
Expand All @@ -54,7 +53,7 @@ const config = {
}
],
'no-unreachable': 'error',
'local-rules/require-data-mapper': 'error',
},
};

module.exports = config;
38 changes: 20 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Lint

on:
pull_request:
Expand All @@ -13,30 +13,26 @@ jobs:
SKIP_ENV_VALIDATION: true

steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
- name: Enable Corepack
run: corepack enable

- name: Use Node 20.x
uses: actions/setup-node@v4
with:
version: 8
node-version: 20.x
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup next cache
with:
path: |
Expand All @@ -49,4 +45,10 @@ jobs:
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Run build
run: pnpm next build
run: pnpm lint

- name: Run tests
run: pnpm test

- name: Run knip
run: pnpm knip
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": ["prettier-plugin-tailwindcss"],
"printWidth": 80,
"quoteProps": "consistent",
"singleQuote": true
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"typescript.enablePromptUseWorkspaceTsdk": true,
"WillLuke.nextjs.addTypesOnSave": true,
"WillLuke.nextjs.hasPrompted": true,
"jest.jestCommandLine": "pnpm run test"
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
}
}
42 changes: 23 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
FROM node:18-alpine AS base
RUN corepack enable
ENV SKIP_ENV_VALIDATION=true
FROM node:lts-alpine AS base

# Install dependencies only when needed
FROM base AS deps

# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
#RUN apk add --no-cache libc6-compat
WORKDIR /app

# Prisma stuff
COPY prisma ./prisma
# Install dependencies
COPY package.json pnpm-lock.yaml* ./
COPY postinstall.mjs ./postinstall.mjs
RUN pnpm install
RUN pnpm prisma generate

# Copy package.json and lockfile, along with postinstall script
COPY package.json pnpm-lock.yaml* postinstall.js migrate-and-start.sh handle-migrations.js ./

# # Install pnpm and install dependencies
RUN corepack enable pnpm && pnpm i --frozen-lockfile

# ---------

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Install git - this is needed to get the app version during build
RUN apk add --no-cache git

ENV NEXT_TELEMETRY_DISABLED 1

# Install git
RUN apk update && apk add --no-cache git

RUN pnpm run build
ENV SKIP_ENV_VALIDATION=true
RUN corepack enable pnpm && pnpm run build

# If using npm comment out above and use below instead
# RUN npm run build
Expand All @@ -39,7 +38,8 @@ FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.

# disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
Expand All @@ -55,13 +55,17 @@ RUN chown nextjs:nodejs .next
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/handle-migrations.js ./
COPY --from=builder --chown=nextjs:nodejs /app/migrate-and-start.sh ./
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma

USER nextjs

EXPOSE 3000

ENV PORT 3000
# set hostname to localhost
ENV HOSTNAME "0.0.0.0"

CMD ["node", "server.js"]
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
# CMD HOSTNAME="0.0.0.0" npm run start:prod
CMD ["sh", "migrate-and-start.sh"]
25 changes: 25 additions & 0 deletions actions/activityFeed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use sever';

import { revalidateTag } from 'next/cache';
import type { Activity, ActivityType } from '~/lib/data-table/types';
import { prisma } from '~/utils/db';

export async function addEvent(
type: ActivityType,
message: Activity['message'],
) {
try {
await prisma.events.create({
data: {
type,
message,
},
});

revalidateTag('activityFeed');

return { success: true, error: null };
} catch (error) {
return { success: false, error: 'Failed to add event' };
}
}
51 changes: 51 additions & 0 deletions actions/appSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use server';

import { revalidateTag } from 'next/cache';
import { redirect } from 'next/navigation';
import { requireApiAuth } from '~/utils/auth';
import { prisma } from '~/utils/db';

export async function setAnonymousRecruitment(input: boolean) {
await requireApiAuth();

await prisma.appSettings.updateMany({
data: {
allowAnonymousRecruitment: input,
},
});

revalidateTag('allowAnonymousRecruitment');

return input;
}

export async function setLimitInterviews(input: boolean) {
await requireApiAuth();
await prisma.appSettings.updateMany({
data: {
limitInterviews: input,
},
});

revalidateTag('limitInterviews');

return input;
}

export const setAppConfigured = async () => {
await requireApiAuth();

try {
await prisma.appSettings.updateMany({
data: {
configured: true,
},
});

revalidateTag('appSettings');
} catch (error) {
return { error: 'Failed to update appSettings', appSettings: null };
}

redirect('/dashboard');
};
Loading

0 comments on commit 632e710

Please sign in to comment.