Skip to content

Commit

Permalink
Merge branch 'main' into dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesread authored Sep 9, 2024
2 parents 9e58dd0 + 89127fb commit b005a96
Show file tree
Hide file tree
Showing 22 changed files with 621 additions and 422 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Build

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: ['20.17.0']
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

# https://nextjs.org/docs/pages/building-your-application/deploying/ci-build-caching#github-actions
- uses: actions/cache@v4
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- run: npm ci
- run: npm run build
36 changes: 36 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: "Code Quality Analysis"

on:
push:
pull_request:

jobs:
analyze:
name: Analyze (${{ matrix.language }})

runs-on: 'ubuntu-latest'
permissions:
security-events: write

strategy:
fail-fast: false
matrix:
include:
- language: javascript-typescript
build-mode: none

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
47 changes: 47 additions & 0 deletions .github/workflows/eslint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: ESLint

on:
push:
pull_request:

jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
strategy:
matrix:
service: ["backend", "frontend"]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: |
**/package-lock.json
- name: Install ESLint
run: |
npm install eslint
npm install @microsoft/[email protected]
- name: Run ESLint
run: npx eslint apps/${{ matrix.service }}/
--config apps/${{ matrix.service }}/.eslintrc.json
--format @microsoft/eslint-formatter-sarif
--output-file apps/${{ matrix.service }}/eslint-results.sarif
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: apps/${{ matrix.service }}/eslint-results.sarif
wait-for-processing: true
15 changes: 7 additions & 8 deletions apps/backend/src/api/routes/posts.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,18 @@ export class PostsController {
@GetOrgFromRequest() org: Organization,
@Query() query: GetPostsDto
) {
const [posts, comments] = await Promise.all([
const [posts] = await Promise.all([
this._postsService.getPosts(org.id, query),
this._commentsService.getAllCommentsByWeekYear(
org.id,
query.year,
query.week,
query.isIsoWeek === 'true'
),
// this._commentsService.getAllCommentsByWeekYear(
// org.id,
// query.year,
// query.week
// ),
]);

return {
posts,
comments,
// comments,
};
}

Expand Down
14 changes: 8 additions & 6 deletions apps/docs/emails.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ title: Email Notifications
description: How to send notifications to users
---

At the moment we are using Resend to send email notifications to users, and might be changed the Novu later.
Postiz uses Resend to send email notifications to users. Emails are currently
required as part of the new-user creation process, which sends an activation
email.

Register to [Resend](https://resend.com) connect your domain.
Copy your API Key.
Head over to .env file and add the following line.
* Register to [Resend](https://resend.com), and connect your domain.
* Copy your API Key from the Resend control panel.
* Open the .env file and edit the following line.

```env
RESEND_API_KEY=""
RESEND_API_KEY="<your-api-key-here>"
```

Feel free to contribute other providers to send email notifications.
Feel free to contribute other providers to send email notifications.
12 changes: 6 additions & 6 deletions apps/docs/howitworks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Unlike other NX project, this project has one `.env` file that is shared between
It makes it easier to develop and deploy the project.<br /><br />
When deploying to websites like [Railway](https://railway.app) or [Heroku](https://heroku.com), you can use a shared environment variables for all the apps.<br /><br />

**At the moment it has 6 project:**
**At the moment it has 6 projects:**

- **Backend** - NestJS based system
- **Workers** - NestJS based workers connected to a Redis Queue.
- **Cron** - NestJS scheduler to run cron jobs.
- **Frontend** - NextJS based control panel.
- **Docs** - Mintlify based documentation website.
- [Frontend](#frontend) - Provides the Web user interface, talks to the Backend.
- [Backend](#backend) - Does all the real work, provides an API for the frontend, and posts work to the redis queue.
- [Workers](#worker) - Consumes work from the Redis Queue.
- [Cron](#cron) - Run jobs at scheduled times.
- [Docs](#docs) - This documentation site!

<img
src="/images/arch.png"
Expand Down
40 changes: 21 additions & 19 deletions apps/docs/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
title: 'Quickstart'
---

At the moment it is necessary to build the project locally - some dependencies
like redis and postgres can run as docker containers, but there is no docker
container for Postiz just yet.

## Prerequisites

To run the project you need to have multiple things:
Expand All @@ -17,25 +21,29 @@ To run the project you need to have multiple things:

A complete guide of how to install NodeJS can be found [here](https://nodejs.org/en/download/).

### PostgreSQL (or any other SQL database)
### PostgreSQL (or any other SQL database) & Redis

Make sure you have PostgreSQL installed on your machine.

Make sure you have PostgreSQL installed on your machine.<br />
If you don't, you can install [Docker](https://www.docker.com/products/docker-desktop) and run:
#### Option A) Postgres and Redis as Single containers

```bash
You can install [Docker](https://www.docker.com/products/docker-desktop) and run:

```bash Terminal
docker run -e POSTGRES_USER=root -e POSTGRES_PASSWORD=your_password --name postgres -p 5432:5432 -d postgres
docker run --name redis -p 6379:6379 -d redis
```

### Redis
#### Option B) Postgres and Redis as docker-compose

Make sure you have Redis installed on your machine.<br />
If you don't, you can install [Docker](https://www.docker.com/products/docker-desktop) and run:
Download the [docker-compose.yaml file here](https://raw.githubusercontent.com/gitroomhq/postiz-app/main/docker-compose.dev.yaml),
or grab it from the repository in the next step.

```bash
docker run --name redis -p 6379:6379 -d redis
```bash Terminal
docker compose -f "docker-compose.dev.yaml" up
```

## Installation
## Build Postiz

<Steps>
<Step title="Clone the repository">
Expand All @@ -44,11 +52,11 @@ git clone https://github.com/gitroomhq/gitroom
```
</Step>

<Step title="Copy environment variables">
<Step title="Set environment variables">
Copy the `.env.example` file to `.env` and fill in the values

```bash .env
DATABASE_URL="postgres database URL"
DATABASE_URL="postgres database URL i.g. postgresql://postiz-local:[email protected]:5432/postiz-db-local"
REDIS_URL="redis database URL"
JWT_SECRET="random string for your JWT secret, make it long"
FRONTEND_URL="By default: http://localhost:4200"
Expand All @@ -73,21 +81,15 @@ CLOUDFLARE_BUCKET_URL="Cloudflare R2 Backet URL"
NX_ADD_PLUGINS=false
IS_GENERAL="true" # required for now
```

</Step>

<Step title="Install the dependencies">

```bash Terminal
npm install
```
</Step>

<Step title="Setup postgres & redis via docker compose">
```bash Terminal
docker compose -f "docker-compose.dev.yaml" up
```
</Step>

<Step title="Generate the prisma client and run the migrations">
```bash Terminal
npm run prisma-db-push
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/app/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
--color-custom20: #121b2c;
--color-custom21: #506490;
--color-custom22: #b91c1c;
--color-custom23: #06080d;
--color-custom23: #000000;
--color-custom24: #eaff00;
--color-custom25: #2e3336;
--color-custom26: #1d9bf0;
Expand Down
8 changes: 2 additions & 6 deletions apps/frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import interClass from '@gitroom/react/helpers/inter.font';

export const dynamic = 'force-dynamic';
import './global.scss';
import 'react-tooltip/dist/react-tooltip.css';
import '@copilotkit/react-ui/styles.css';

import LayoutContext from '@gitroom/frontend/components/layout/layout.context';
import { ReactNode } from 'react';
import { Chakra_Petch } from 'next/font/google';
import { isGeneral } from '@gitroom/react/helpers/is.general';
import PlausibleProvider from 'next-plausible';
import clsx from 'clsx';

const chakra = Chakra_Petch({ weight: '400', subsets: ['latin'] });
import "@fontsource/chakra-petch";

export default async function AppLayout({ children }: { children: ReactNode }) {
return (
Expand All @@ -24,7 +20,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
sizes="any"
/>
</head>
<body className={clsx(chakra.className, 'text-primary dark')}>
<body className={clsx('chakra-petch', 'text-primary dark')}>
<PlausibleProvider domain={isGeneral() ? "postiz.com" : "gitroom.com"}>
<LayoutContext>{children}</LayoutContext>
</PlausibleProvider>
Expand Down
13 changes: 5 additions & 8 deletions apps/frontend/src/components/launches/add.edit.model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import React, {
import dayjs from 'dayjs';
import { Integrations } from '@gitroom/frontend/components/launches/calendar.context';
import clsx from 'clsx';
import { commands } from '@uiw/react-md-editor';
import { usePreventWindowUnload } from '@gitroom/react/helpers/use.prevent.window.unload';
import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
import { useModals } from '@mantine/modals';
Expand All @@ -27,16 +26,14 @@ import {
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
import { useMoveToIntegration } from '@gitroom/frontend/components/launches/helpers/use.move.to.integration';
import { useExistingData } from '@gitroom/frontend/components/launches/helpers/use.existing.data';
import { newImage } from '@gitroom/frontend/components/launches/helpers/new.image.component';
import { MultiMediaComponent } from '@gitroom/frontend/components/media/media.component';
import { useExpend } from '@gitroom/frontend/components/launches/helpers/use.expend';
import { TopTitle } from '@gitroom/frontend/components/launches/helpers/top.title.component';
import { PickPlatforms } from '@gitroom/frontend/components/launches/helpers/pick.platform.component';
import { ProvidersOptions } from '@gitroom/frontend/components/launches/providers.options';
import { v4 as uuidv4 } from 'uuid';
import useSWR, { useSWRConfig } from 'swr';
import useSWR from 'swr';
import { useToaster } from '@gitroom/react/toaster/toaster';
import { postSelector } from '@gitroom/frontend/components/post-url-selector/post.url.selector';
import { UpDownArrow } from '@gitroom/frontend/components/launches/up.down.arrow';
import { DatePicker } from '@gitroom/frontend/components/launches/helpers/date.picker';
import { arrayMoveImmutable } from 'array-move';
Expand All @@ -56,10 +53,10 @@ export const AddEditModal: FC<{
date: dayjs.Dayjs;
integrations: Integrations[];
reopenModal: () => void;
mutate: () => void;
}> = (props) => {
const { date, integrations, reopenModal } = props;
const { date, integrations, reopenModal, mutate } = props;
const [dateState, setDateState] = useState(date);
const { mutate } = useSWRConfig();

// hook to open a new modal
const modal = useModals();
Expand Down Expand Up @@ -246,7 +243,7 @@ export const AddEditModal: FC<{
await fetch(`/posts/${existingData.group}`, {
method: 'DELETE',
});
mutate('/posts');
mutate();
modal.closeAll();
return;
}
Expand Down Expand Up @@ -324,7 +321,7 @@ export const AddEditModal: FC<{

existingData.group = uuidv4();

mutate('/posts');
mutate();
toaster.show(
!existingData.integration
? 'Added successfully'
Expand Down
Loading

0 comments on commit b005a96

Please sign in to comment.