Initial user table, removed more cruft and fixed some scripts

This commit is contained in:
Matt Aitken
2022-12-06 13:23:38 +00:00
parent d06e20eb12
commit cf05e09a04
17 changed files with 12468 additions and 707 deletions
+58 -55
View File
@@ -26,7 +26,7 @@ new Workflow({
} else {
await upsertIssue(data);
}
}
},
}).listen();
```
@@ -112,60 +112,63 @@ new Workflow({
> All the following commands should be launched from the **monorepo root directory**
1. Install the dependencies.
```bash
pnpm install
```
You also have to copy the example .env.example:
```sh
cp .env.example .env
cp .env.example .env.docker
```
2. Start the postgresql docker container
```bash
pnpm run docker:db
```
> **Note:** The npm script will complete while Docker sets up the container in the background. Ensure that Docker has finished and your container is running before proceeding.
```bash
pnpm install
```
2. Environment variables. You will need to create copies of the `.env.example` files in `app/webapp`
```sh
cp ./apps/webapp/.env.example ./apps/webapp/.env
```
3. Start the postgresql docker container
```bash
pnpm run docker:db
```
> **Note:** The npm script will complete while Docker sets up the container in the background. Ensure that Docker has finished and your container is running before proceeding.
4. Generate prisma schema
```bash
pnpm run generate
```
5. Run the Prisma migration to the database
```bash
pnpm run db:migrate:deploy
```
6. Run the first build (with dependencies via the `...` option)
```bash
pnpm run build --filter=webapp...
```
**Running simply `pnpm run build` will build everything, including the NextJS app.**
7. Run the Remix dev server
```bash
pnpm run dev --filter=webapp
```
3. Generate prisma schema
```bash
pnpm run generate
```
4. Run the Prisma migration to the database
```bash
pnpm run db:migrate:deploy
```
5. Run the first build (with dependencies via the `...` option)
```bash
pnpm run build --filter=webapp...
```
**Running simply `pnpm run build` will build everything, including the NextJS app.**
6. Run the Remix dev server
```bash
pnpm run dev --filter=webapp
```
## Tests, Typechecks, Lint, Install packages...
Check the `turbo.json` file to see the available pipelines.
- Run the Cypress tests and Dev
```bash
pnpm run test:e2e:dev --filter=webapp
```
- Lint everything
```bash
pnpm run lint
```
- Typecheck the whole monorepo
```bash
pnpm run typecheck
```
- Test the whole monorepo
```bash
pnpm run test
or
pnpm run test:dev
```
- How to install an npm package in the Remix app ?
```bash
pnpm add dayjs --filter webapp
```
- Tweak the tsconfigs, eslint configs in the `config-package` folder. Any package or app will then extend from these configs.
Check the `turbo.json` file to see the available pipelines.
- Run the Cypress tests and Dev
```bash
pnpm run test:e2e:dev --filter=webapp
```
- Lint everything
```bash
pnpm run lint
```
- Typecheck the whole monorepo
```bash
pnpm run typecheck
```
- Test the whole monorepo
```bash
pnpm run test
or
pnpm run test:dev
```
- How to install an npm package in the Remix app ?
```bash
pnpm add dayjs --filter webapp
```
- Tweak the tsconfigs, eslint configs in the `config-package` folder. Any package or app will then extend from these configs.
+1
View File
@@ -0,0 +1 @@
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
+45
View File
@@ -0,0 +1,45 @@
import { DocumentTextIcon } from "@heroicons/react/24/solid";
import { Link } from "@remix-run/react";
import { useUser } from "~/utils";
import { Logo } from "./Logo";
import { UserProfileMenu } from "./UserProfileMenu";
type HeaderProps = {
children?: React.ReactNode;
};
export function Header({ children }: HeaderProps) {
const user = useUser();
return (
<div className="flex w-full items-center border-b border-slate-200 bg-white py-1 px-2">
<Link to="/" aria-label="API Hero">
<Logo className="h-6" />
</Link>
<div className="flex flex-1 justify-center">{children}</div>
<div className="flex items-center gap-2">
<a
href="https://docs.apihero.run"
target="_blank"
className="group flex items-center justify-center gap-1 rounded border border-slate-200 bg-white py-1 px-2 text-sm text-slate-700 shadow-sm transition hover:bg-slate-50 hover:text-blue-600"
rel="noreferrer"
>
<DocumentTextIcon className="h-4 w-4 transition group-hover:text-blue-600" />
<span>Docs</span>
</a>
{user ? (
<UserProfileMenu user={user} />
) : (
<Link
to="/login"
className="text-gray-700 transition hover:text-black"
>
Login
</Link>
)}
</div>
</div>
);
}
+163
View File
@@ -0,0 +1,163 @@
export function Logo({
className,
width = "100%",
}: {
className?: string;
width?: string;
}) {
return (
<svg
width="120"
height="32"
viewBox="0 0 153 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
d="M15.5 31.366C23.5081 31.366 30 24.8564 30 16.8265C30 8.79654 23.5081 2.28699 15.5 2.28699C7.49187 2.28699 1 8.79654 1 16.8265C1 24.8564 7.49187 31.366 15.5 31.366Z"
fill="#2463EB"
/>
<path
d="M23.5827 17.5438C23.7442 17.4031 23.875 17.2307 23.9672 17.0372C24.0593 16.8437 24.1107 16.6332 24.1182 16.4189C24.1258 16.2046 24.0892 15.991 24.0109 15.7915C23.9326 15.592 23.8141 15.4107 23.6629 15.2591C23.5117 15.1074 23.331 14.9886 23.1321 14.91C22.9331 14.8313 22.7201 14.7946 22.5064 14.8021C22.2927 14.8095 22.0828 14.861 21.8897 14.9533C21.6967 15.0457 21.5247 15.1768 21.3844 15.3387C21.9914 14.7299 22.4497 13.2836 21.8426 12.6749C21.2348 12.0662 19.7923 12.5256 19.1853 13.1343C19.7923 12.5256 20.2505 11.0793 19.6435 10.4698C19.0364 9.86027 17.594 10.3205 16.9869 10.9292C17.1336 10.7813 17.2492 10.6054 17.3271 10.412C17.4049 10.2185 17.4433 10.0114 17.44 9.80285C17.4367 9.59428 17.3919 9.38848 17.308 9.19758C17.2242 9.00668 17.1031 8.83453 16.9519 8.6913C16.3323 8.10603 15.3434 8.16698 14.7418 8.76944L12.8427 10.6753C12.8059 10.7115 12.7713 10.7498 12.7391 10.7901L12.7336 10.7847L9.68433 13.8415C9.37078 14.1558 9.12206 14.529 8.95236 14.9398C8.78267 15.3505 8.69533 15.7907 8.69533 16.2353C8.69533 16.6799 8.78267 17.1201 8.95236 17.5309C9.12206 17.9416 9.37078 18.3148 9.68433 18.6291L9.25183 18.1955L1.79883 21.8571C2.4729 24.0372 3.39245 25.5109 5.11387 27.2409C6.83529 28.9709 8.20526 30.1032 10.381 30.7799L14.1379 23.0917L13.7054 22.658C14.0188 22.9724 14.3909 23.2218 14.8005 23.3919C15.21 23.5621 15.649 23.6496 16.0923 23.6496C16.5356 23.6496 16.9746 23.5621 17.3842 23.3919C17.7937 23.2218 18.1658 22.9724 18.4792 22.658L21.5286 19.6004L21.5231 19.5949C21.5633 19.5626 21.6016 19.5279 21.6377 19.491L23.5827 17.5438Z"
fill="#FBBF24"
/>
<path
opacity="0.6"
d="M18.6334 22.5033L19.8514 21.1937L12.6992 13.8634L12.4576 16.3311L15.3176 19.1988L13.9149 19.1339L11.1562 16.485L11.3776 17.7485L13.0787 19.4543C13.4194 19.7958 13.8757 19.9961 14.357 20.0155C14.8383 20.0349 15.3092 19.8719 15.6761 19.559L18.6334 22.5033Z"
fill="#D0830B"
/>
<path
opacity="0.6"
d="M13.6048 22.6675L13.2487 22.4283L9.604 30.0884L10.4628 30.376L14.0958 23.1597L13.6048 22.6675Z"
fill="#D0830B"
/>
<path
d="M12.7336 10.7816L9.68425 13.8392C9.37072 14.1535 9.12202 14.5266 8.95233 14.9373C8.78265 15.348 8.69531 15.7881 8.69531 16.2327C8.69531 16.6772 8.78265 17.1173 8.95233 17.528C9.12202 17.9387 9.37072 18.3118 9.68425 18.6261"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M21.5287 19.6005L18.4794 22.6581C18.166 22.9725 17.7939 23.2218 17.3843 23.392C16.9748 23.5621 16.5358 23.6497 16.0925 23.6497C15.6492 23.6497 15.2102 23.5621 14.8007 23.392C14.3911 23.2218 14.019 22.9725 13.7056 22.6581"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M14.1377 23.0909L10.3823 30.7768"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M9.25183 18.1924L1.79883 21.854"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M15.5 31.366C23.5081 31.366 30 24.8564 30 16.8265C30 8.79654 23.5081 2.28699 15.5 2.28699C7.49187 2.28699 1 8.79654 1 16.8265C1 24.8564 7.49187 31.366 15.5 31.366Z"
stroke="#0F3077"
strokeWidth="1.00267"
strokeMiterlimit="10"
/>
<path
d="M9.68055 8.05759L2.61719 1L6.9975 13.6719L7.19466 9.95092L22.6236 25.4218L22.8402 22.433L29.948 29.5351L25.4383 16.5811L25.111 20.3091L9.83641 5.12891L9.68055 8.05759Z"
fill="#FDE047"
stroke="#0F172A"
strokeWidth="0.452634"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M16.9831 10.9284C17.5902 10.3196 17.5902 9.33255 16.9831 8.72376C16.376 8.11498 15.3916 8.11498 14.7845 8.72376L12.8421 10.6714C12.235 11.2802 12.235 12.2673 12.8421 12.876C13.4492 13.4848 14.4336 13.4848 15.0407 12.876L16.9831 10.9284Z"
fill="#FBBF24"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M19.7087 12.6052C20.3158 11.9965 20.3158 11.0094 19.7087 10.4006C19.1016 9.79186 18.1172 9.79186 17.5101 10.4006L15.0409 12.8765C14.4338 13.4853 14.4338 14.4724 15.0409 15.0811C15.648 15.6899 16.6324 15.6899 17.2395 15.0811L19.7087 12.6052Z"
fill="#FBBF24"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M21.9084 14.8104C22.5155 14.2017 22.5155 13.2146 21.9084 12.6058C21.3013 11.9971 20.3169 11.9971 19.7098 12.6058L17.2406 15.0817C16.6335 15.6905 16.6335 16.6776 17.2406 17.2863C17.8477 17.8951 18.8321 17.8951 19.4392 17.2863L21.9084 14.8104Z"
fill="#FBBF24"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M23.5798 17.5432C24.1869 16.9344 24.1869 15.9474 23.5798 15.3386C22.9726 14.7298 21.9883 14.7298 21.3812 15.3386L19.4388 17.2863C18.8316 17.8951 18.8316 18.8821 19.4388 19.4909C20.0459 20.0997 21.0303 20.0997 21.6374 19.4909L23.5798 17.5432Z"
fill="#FBBF24"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M10.1455 13.3758C10.4376 13.0842 10.8329 12.9205 11.2451 12.9205C11.6572 12.9205 12.0525 13.0842 12.3446 13.3758L15.5147 16.5545C15.8055 16.8474 15.9687 17.2438 15.9687 17.657C15.9687 18.0703 15.8055 18.4667 15.5147 18.7596V18.7596C15.2226 19.0511 14.8273 19.2148 14.4152 19.2148C14.003 19.2148 13.6077 19.0511 13.3156 18.7596"
fill="#FBBF24"
/>
<path
d="M10.1455 13.3758C10.4376 13.0842 10.8329 12.9205 11.2451 12.9205C11.6572 12.9205 12.0525 13.0842 12.3446 13.3758L15.5147 16.5545C15.8055 16.8474 15.9687 17.2438 15.9687 17.657C15.9687 18.0703 15.8055 18.4667 15.5147 18.7596V18.7596C15.2226 19.0511 14.8273 19.2148 14.4152 19.2148C14.003 19.2148 13.6077 19.0511 13.3156 18.7596"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M8.55745 19.8278L3.8623 22.1462"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
strokeLinecap="round"
/>
<path
d="M14.879 11.0002L14.7132 10.8339C14.4655 10.5855 14.0638 10.5855 13.8161 10.8339L13.2866 11.3649C13.0388 11.6133 13.0388 12.016 13.2866 12.2644L13.4524 12.4307C13.7001 12.6791 14.1018 12.6791 14.3495 12.4307L14.879 11.8997C15.1268 11.6514 15.1268 11.2486 14.879 11.0002Z"
fill="#F59E0B"
/>
<path
d="M14.5073 16.6832C14.2136 16.3887 13.7376 16.3886 13.4441 16.6829C13.1505 16.9772 13.1507 17.4545 13.4443 17.749L13.8075 18.1131C14.1011 18.4076 14.5772 18.4077 14.8707 18.1134C15.1642 17.8191 15.1641 17.3418 14.8704 17.0473L14.5073 16.6832Z"
fill="#F59E0B"
/>
<path
d="M17.0788 13.2048L16.9129 13.0385C16.6652 12.7901 16.2635 12.7901 16.0158 13.0385L15.4863 13.5695C15.2386 13.8179 15.2386 14.2206 15.4863 14.469L15.6521 14.6353C15.8999 14.8837 16.3015 14.8837 16.5492 14.6353L17.0788 14.1043C17.3265 13.8559 17.3265 13.4532 17.0788 13.2048Z"
fill="#F59E0B"
/>
<path
d="M19.278 15.4098L19.1121 15.2435C18.8644 14.9951 18.4628 14.9951 18.215 15.2435L17.6855 15.7744C17.4378 16.0228 17.4378 16.4256 17.6855 16.674L17.8514 16.8403C18.0991 17.0887 18.5007 17.0887 18.7484 16.8403L19.278 16.3093C19.5257 16.0609 19.5257 15.6582 19.278 15.4098Z"
fill="#F59E0B"
/>
<path
d="M21.4762 17.6138L21.3104 17.4474C21.0626 17.199 20.661 17.199 20.4133 17.4474L19.8837 17.9784C19.636 18.2268 19.636 18.6296 19.8837 18.8779L20.0496 19.0443C20.2973 19.2927 20.699 19.2927 20.9467 19.0443L21.4762 18.5133C21.7239 18.2649 21.7239 17.8622 21.4762 17.6138Z"
fill="#F59E0B"
/>
<path
d="M9.76514 13.7664L10.2483 13.282"
stroke="#0F172A"
strokeWidth="0.396771"
strokeMiterlimit="10"
/>
<path
d="M10.3032 19.5528L9.53174 18.7792L9.83721 18.4729L11.0887 19.7278C11.0981 19.7368 11.104 19.7488 11.1056 19.7617C11.1071 19.7747 11.1041 19.7877 11.0971 19.7987C11.0901 19.8096 11.0796 19.8178 11.0673 19.8219C11.0549 19.8259 11.0416 19.8255 11.0295 19.8208L10.3032 19.5528Z"
fill="#0F172A"
/>
<path d="M13.3155 18.7597L11.1577 16.5952Z" fill="#FBBF24" />
<path
d="M13.1631 18.9128L11.0053 16.7483L10.9016 16.1779C10.8997 16.166 10.9015 16.1539 10.9069 16.1432C10.9123 16.1324 10.9209 16.1237 10.9315 16.1181C10.9421 16.1126 10.9542 16.1106 10.9661 16.1123C10.9779 16.1141 10.9889 16.1195 10.9975 16.1279L13.4686 18.6065L13.1631 18.9128Z"
fill="#0F172A"
/>
<path
d="M13.5527 22.8112L13.0361 22.2932C13.0269 22.2844 13.0209 22.2728 13.0191 22.2602C13.0173 22.2476 13.0199 22.2348 13.0263 22.2238C13.0327 22.2129 13.0426 22.2044 13.0545 22.1998C13.0663 22.1952 13.0793 22.1948 13.0914 22.1986L13.7382 22.3846L13.8582 22.5049L13.5527 22.8112Z"
fill="#0F172A"
/>
<path
d="M35.6 25L42.104 8.2H44.744L51.2 25H48.44L44.6 14.872C44.552 14.76 44.456 14.488 44.312 14.056C44.184 13.624 44.032 13.144 43.856 12.616C43.68 12.088 43.52 11.608 43.376 11.176C43.232 10.728 43.136 10.44 43.088 10.312L43.64 10.288C43.544 10.56 43.424 10.904 43.28 11.32C43.152 11.736 43.008 12.176 42.848 12.64C42.704 13.104 42.56 13.544 42.416 13.96C42.272 14.36 42.152 14.696 42.056 14.968L38.24 25H35.6ZM38.48 20.824L39.44 18.328H47.072L48.176 20.824H38.48ZM54.1567 25V8.2H60.9967C61.9087 8.2 62.7327 8.432 63.4687 8.896C64.2207 9.344 64.8207 9.96 65.2687 10.744C65.7167 11.528 65.9407 12.4 65.9407 13.36C65.9407 14.32 65.7167 15.192 65.2687 15.976C64.8207 16.76 64.2207 17.392 63.4687 17.872C62.7327 18.336 61.9087 18.568 60.9967 18.568H56.7487V25H54.1567ZM56.7487 16.072H60.9487C61.3807 16.072 61.7727 15.952 62.1247 15.712C62.4767 15.456 62.7567 15.128 62.9647 14.728C63.1887 14.312 63.3007 13.856 63.3007 13.36C63.3007 12.864 63.1887 12.416 62.9647 12.016C62.7567 11.616 62.4767 11.296 62.1247 11.056C61.7727 10.816 61.3807 10.696 60.9487 10.696H56.7487V16.072ZM68.7436 25V22.6H71.4556V10.6H68.7436V8.2H76.7596V10.6H74.0476V22.6H76.7596V25H68.7436ZM91.0046 25V8.2H95.0846V25H91.0046ZM80.5886 25V8.2H84.6686V25H80.5886ZM82.1726 18.448L82.1966 14.8H93.1646V18.448H82.1726ZM99.2917 25V8.2H111.004V11.68H103.252V21.52H111.244V25H99.2917ZM101.212 18.112V14.8H109.924V18.112H101.212ZM114.76 25V8.2H122.32C123.392 8.2 124.36 8.432 125.224 8.896C126.104 9.36 126.792 10 127.288 10.816C127.784 11.616 128.032 12.528 128.032 13.552C128.032 14.608 127.784 15.56 127.288 16.408C126.792 17.24 126.112 17.896 125.248 18.376C124.384 18.856 123.408 19.096 122.32 19.096H118.648V25H114.76ZM124.072 25L119.8 17.416L123.976 16.816L128.728 25H124.072ZM118.648 15.976H121.96C122.376 15.976 122.736 15.888 123.04 15.712C123.36 15.52 123.6 15.256 123.76 14.92C123.936 14.584 124.024 14.2 124.024 13.768C124.024 13.336 123.928 12.96 123.736 12.64C123.544 12.304 123.264 12.048 122.896 11.872C122.544 11.696 122.112 11.608 121.6 11.608H118.648V15.976ZM139.034 25.24C137.754 25.24 136.586 25.024 135.53 24.592C134.474 24.16 133.554 23.552 132.77 22.768C131.986 21.984 131.378 21.064 130.946 20.008C130.514 18.952 130.298 17.792 130.298 16.528C130.298 15.264 130.514 14.104 130.946 13.048C131.378 11.992 131.986 11.072 132.77 10.288C133.554 9.504 134.474 8.896 135.53 8.464C136.586 8.032 137.746 7.816 139.01 7.816C140.274 7.816 141.434 8.032 142.49 8.464C143.546 8.896 144.466 9.504 145.25 10.288C146.034 11.072 146.634 11.992 147.05 13.048C147.482 14.104 147.698 15.264 147.698 16.528C147.698 17.776 147.482 18.936 147.05 20.008C146.634 21.064 146.034 21.984 145.25 22.768C144.466 23.552 143.546 24.16 142.49 24.592C141.434 25.024 140.282 25.24 139.034 25.24ZM139.01 21.4C139.666 21.4 140.266 21.28 140.81 21.04C141.37 20.8 141.85 20.464 142.25 20.032C142.666 19.584 142.986 19.064 143.21 18.472C143.434 17.88 143.546 17.232 143.546 16.528C143.546 15.824 143.434 15.176 143.21 14.584C142.986 13.992 142.666 13.48 142.25 13.048C141.85 12.6 141.37 12.256 140.81 12.016C140.266 11.776 139.666 11.656 139.01 11.656C138.354 11.656 137.746 11.776 137.186 12.016C136.642 12.256 136.162 12.6 135.746 13.048C135.33 13.48 135.01 13.992 134.786 14.584C134.578 15.176 134.474 15.824 134.474 16.528C134.474 17.232 134.578 17.888 134.786 18.496C135.01 19.088 135.33 19.6 135.746 20.032C136.162 20.464 136.642 20.8 137.186 21.04C137.746 21.28 138.354 21.4 139.01 21.4Z"
fill="#112A6C"
/>
</svg>
);
}
@@ -0,0 +1,55 @@
import { Menu, Transition } from "@headlessui/react";
import classnames from "classnames";
import type { User } from "~/models/user.server";
// import { UserProfilePhoto } from "./UserProfilePhoto";
const userNavigation = [{ name: "Logout", href: "/logout" }];
export function UserProfileMenu({ user }: { user: User }) {
return (
<Menu as="div" className="relative z-50 ml-1">
<div>
<Menu.Button className="transitions flex max-w-xs items-center rounded-full bg-white text-sm">
<span className="sr-only">Open user menu</span>
{/* <UserProfilePhoto user={user} className="h-7 w-7" /> */}
</Menu.Button>
</div>
<Transition
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Menu.Items className="absolute right-0 mt-2 w-48 origin-top-right rounded-md bg-white pb-2 pt-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
{/* {user.name ? (
<h2 className="mb-2 block border-b border-slate-200 py-2 pl-5 pr-2 text-sm font-semibold text-slate-600">
{user.name}
</h2>
) : (
<h2 className="mb-2 block border-b border-slate-200 py-2 pl-5 pr-2 text-sm font-semibold text-slate-600">
{user.email}
</h2>
)} */}
{userNavigation.map((item) => (
<Menu.Item key={item.name}>
{({ active }) => (
<a
href={item.href}
className={classnames(
active ? "bg-rose-100 text-rose-700" : "",
"mx-2 block rounded-md p-2 pl-3 text-sm text-slate-700"
)}
>
{item.name}
</a>
)}
</Menu.Item>
))}
</Menu.Items>
</Transition>
</Menu>
);
}
+65
View File
@@ -0,0 +1,65 @@
import type { Session } from "@remix-run/node";
import { redirect } from "remix-typedjson";
import { createCookieSessionStorage } from "@remix-run/node";
import invariant from "tiny-invariant";
export type ToastMessage = { message: string; type: "success" | "error" };
const ONE_YEAR = 1000 * 60 * 60 * 24 * 365;
invariant(process.env.SESSION_SECRET, "SESSION_SECRET must be set");
export const { commitSession, getSession } = createCookieSessionStorage({
cookie: {
name: "__message",
path: "/",
httpOnly: true,
sameSite: "lax",
secrets: [process.env.SESSION_SECRET],
secure: process.env.NODE_ENV === "production",
},
});
export function setSuccessMessage(session: Session, message: string) {
session.flash("toastMessage", { message, type: "success" } as ToastMessage);
}
export function setErrorMessage(session: Session, message: string) {
session.flash("toastMessage", { message, type: "error" } as ToastMessage);
}
export async function redirectWithSuccessMessage(
path: string,
request: Request,
message: string
) {
const session = await getSession(request.headers.get("cookie"));
setSuccessMessage(session, message);
return redirect(path, {
headers: {
"Set-Cookie": await commitSession(session, {
expires: new Date(Date.now() + ONE_YEAR),
}),
},
});
}
export async function redirectWithErrorMessage(
path: string,
request: Request,
message: string
) {
const session = await getSession(request.headers.get("cookie"));
setErrorMessage(session, message);
return redirect(path, {
headers: {
"Set-Cookie": await commitSession(session, {
expires: new Date(Date.now() + ONE_YEAR),
}),
},
});
}
+1 -1
View File
@@ -1,6 +1,6 @@
import { BookOpenIcon } from "@heroicons/react/24/solid";
import { Link, Outlet } from "@remix-run/react";
import { Header } from "~/libraries/ui";
import { Header } from "~/components/Header";
const pages = [
{
+4 -3
View File
@@ -1,10 +1,11 @@
import { redirect } from "@remix-run/node";
import { getUserById } from "~/models/user.server";
import { authenticator } from "./auth.server";
export async function getUserId(request: Request): Promise<string | undefined> {
let authUser = await authenticator.isAuthenticated(request);
return authUser?.userId;
//todo get the user id from the session
// let authUser = await authenticator.isAuthenticated(request);
// return authUser?.userId;
return undefined;
}
export async function getUser(request: Request) {
+3 -49
View File
@@ -17,7 +17,7 @@
"generate:css": "tailwindcss --postcss -i ./styles/tailwind-include.css -o ./app/styles/tailwind.css",
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
"start": "cross-env NODE_ENV=production node ./build/server.js",
"docker:build": "cd ../.. && docker build -t remix-gospel-stack-webapp -f ./apps/webapp/Dockerfile .",
"docker:build": "cd ../.. && docker build -t trigger-webapp -f ./apps/webapp/Dockerfile .",
"test": "vitest run",
"test:cov": "vitest run --coverage",
"test:e2e:dev": "start-server-and-test dev http://localhost:3000 \"npx cypress open\"",
@@ -36,10 +36,6 @@
"/public/build"
],
"dependencies": {
"@apihero/openapi-spec-generator": "^0.1.6",
"@aws-sdk/client-s3": "^3.186.0",
"@aws-sdk/s3-request-presigner": "^3.186.0",
"@cfworker/json-schema": "^1.12.4",
"@codemirror/autocomplete": "^6.3.1",
"@codemirror/commands": "^6.1.2",
"@codemirror/lang-javascript": "^6.1.1",
@@ -50,101 +46,60 @@
"@codemirror/view": "^6.5.0",
"@headlessui/react": "^1.6.4",
"@heroicons/react": "^2.0.12",
"@keyv/redis": "^2.3.7",
"@lezer/highlight": "^1.1.2",
"@prisma/client": "^4.3.0",
"@remix-run/express": "^1.7.2",
"@remix-run/node": "^1.7.2",
"@remix-run/react": "^1.7.2",
"@remix-run/server-runtime": "^1.7.0",
"@sendgrid/client": "^7.7.0",
"@sendgrid/mail": "^7.7.0",
"@sentry/remix": "^7.19.0",
"@tailwindcss/forms": "^0.5.2",
"@tanstack/react-table": "^8.0.0-alpha.87",
"@tremor/react": "^1.1.4",
"@uiw/react-codemirror": "^4.13.2",
"@apihero/node": "workspace:*",
"bcryptjs": "^2.4.3",
"classnames": "^2.3.1",
"clsx": "^1.2.1",
"compression": "^1.7.4",
"cross-env": "^7.0.3",
"csstype": "^3.0.10",
"cuid": "^2.1.8",
"date-fns": "2.0.0-alpha.7 || >=2.0.0",
"express": "^4.18.1",
"internal-logs": "workspace:*",
"javascript-time-ago": "^2.5.7",
"json-query": "^2.2.2",
"jsonata": "^1.8.6",
"jsonschema": "^1.4.1",
"keyv": "^4.3.2",
"lodash": "^4.17.21",
"mailgun-js": "^0.22.0",
"marked": "^4.0.18",
"mergent": "^1.3.1",
"morgan": "^1.10.0",
"nanoid": "^3.3.4",
"openapi-types": "^12.0.0",
"postcss-import": "^14.1.0",
"posthog-js": "^1.31.0",
"pretty-bytes": "^6.0.0",
"prisma-field-encryption": "1.4.0-beta.5",
"qs": "^6.11.0",
"react": "^18.2.0",
"react-date-range": "^1.4.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.0",
"react-hotkeys-hook": "^3.4.7",
"react-query": "^3.39.1",
"react-resizable-layout": "^0.2.4",
"remix-auth": "^3.2.2",
"remix-auth-email-link": "^1.4.2",
"remix-auth-github": "^1.1.1",
"remix-typedjson": "^0.1.3",
"remix-utils": "^3.3.0",
"slug": "^6.0.0",
"tiny-invariant": "^1.2.0",
"tsx": "^3.4.3",
"zod": "^3.17.3",
"zod-to-json-schema": "^3.17.0"
"zod": "^3.17.3"
},
"devDependencies": {
"@apihero/tailwind-config": "*",
"@faker-js/faker": "^7.5.0",
"@remix-run/dev": "^1.7.2",
"@remix-run/eslint-config": "^1.7.2",
"@swc/core": "^1.3.4",
"@swc/helpers": "^0.4.11",
"@tailwindcss/typography": "^0.5.4",
"@testing-library/cypress": "^8.0.3",
"@testing-library/dom": "^8.18.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/bcryptjs": "^2.4.2",
"@types/compression": "^1.7.2",
"@types/eslint": "^8.4.6",
"@types/express": "^4.17.13",
"@types/jest": "^29.2.0",
"@types/json-query": "^2.2.3",
"@types/lodash": "^4.14.182",
"@types/mailgun-js": "^0.22.12",
"@types/marked": "^4.0.3",
"@types/morgan": "^1.9.3",
"@types/node": "^18.8.0",
"@types/node-fetch": "^2.6.2",
"@types/qs": "^6.9.7",
"@types/react": "^18.0.21",
"@types/react-date-range": "^1.4.3",
"@types/react-dom": "^18.0.6",
"@types/slug": "^5.0.3",
"@vitejs/plugin-react": "^2.0.1",
"@vitest/coverage-c8": "^0.23.4",
"autoprefixer": "^10.4.7",
"c8": "^7.11.3",
"cli-ux": "^6.0.9",
"cypress": "^10.9.0",
"dotenv": "^16.0.3",
"esbuild": "^0.15.10",
@@ -161,7 +116,6 @@
"prettier": "^2.6.2",
"prettier-plugin-tailwindcss": "^0.1.11",
"prisma": "^4.3.0",
"react-date-range": "^1.4.0",
"start-server-and-test": "^1.14.0",
"tailwindcss": "^3.0.24",
"ts-node": "^10.7.0",
@@ -174,4 +128,4 @@
"engines": {
"node": ">=14"
}
}
}
@@ -0,0 +1,8 @@
-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
@@ -1,197 +0,0 @@
.rdrCalendarWrapper {
box-sizing: border-box;
background: #ffffff;
display: inline-flex;
flex-direction: column;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.rdrDateDisplay{
display: flex;
justify-content: space-between;
}
.rdrDateDisplayItem{
flex: 1 1;
width: 0;
text-align: center;
color: inherit;
}
.rdrDateDisplayItem + .rdrDateDisplayItem{
margin-left: 0.833em;
}
.rdrDateDisplayItem input{
text-align: inherit
}
.rdrDateDisplayItem input:disabled{
cursor: default;
}
.rdrDateDisplayItemActive{}
.rdrMonthAndYearWrapper {
box-sizing: inherit;
display: flex;
justify-content: space-between;
}
.rdrMonthAndYearPickers{
flex: 1 1 auto;
display: flex;
justify-content: center;
align-items: center;
}
.rdrMonthPicker{}
.rdrYearPicker{}
.rdrNextPrevButton {
box-sizing: inherit;
cursor: pointer;
outline: none;
}
.rdrPprevButton {}
.rdrNextButton {}
.rdrMonths{
display: flex;
}
.rdrMonthsVertical{
flex-direction: column;
}
.rdrMonthsHorizontal > div > div > div{
display: flex;
flex-direction: row;
}
.rdrMonth{
width: 27.667em;
}
.rdrWeekDays{
display: flex;
}
.rdrWeekDay {
flex-basis: calc(100% / 7);
box-sizing: inherit;
text-align: center;
}
.rdrDays{
display: flex;
flex-wrap: wrap;
}
.rdrDateDisplayWrapper{}
.rdrMonthName{}
.rdrInfiniteMonths{
overflow: auto;
}
.rdrDateRangeWrapper{
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.rdrDateInput {
position: relative;
}
.rdrDateInput input {
outline: none;
}
.rdrDateInput .rdrWarning {
position: absolute;
font-size: 1.6em;
line-height: 1.6em;
top: 0;
right: .25em;
color: #FF0000;
}
.rdrDay {
box-sizing: inherit;
width: calc(100% / 7);
position: relative;
font: inherit;
cursor: pointer;
}
.rdrDayNumber {
display: block;
position: relative;
}
.rdrDayNumber span{
color: #1d2429;
}
.rdrDayDisabled {
cursor: not-allowed;
}
@supports (-ms-ime-align: auto) {
.rdrDay {
flex-basis: 14.285% !important;
}
}
.rdrSelected, .rdrInRange, .rdrStartEdge, .rdrEndEdge{
pointer-events: none;
}
.rdrInRange{}
.rdrDayStartPreview, .rdrDayInPreview, .rdrDayEndPreview{
pointer-events: none;
}
.rdrDayHovered{}
.rdrDayActive{}
.rdrDateRangePickerWrapper{
display: inline-flex;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.rdrDefinedRangesWrapper{}
.rdrStaticRanges{
display: flex;
flex-direction: column;
}
.rdrStaticRange{
font-size: inherit;
}
.rdrStaticRangeLabel{}
.rdrInputRanges{}
.rdrInputRange{
display: flex;
}
.rdrInputRangeInput{}
@@ -1,386 +0,0 @@
.rdrCalendarWrapper{
color: #000000;
font-size: 12px;
}
.rdrDateDisplayWrapper{
background-color: rgb(239, 242, 247);
}
.rdrDateDisplay{
margin: 0.833em;
}
.rdrDateDisplayItem{
border-radius: 4px;
background-color: rgb(255, 255, 255);
box-shadow: 0 1px 2px 0 rgba(35, 57, 66, 0.21);
border: 1px solid transparent;
}
.rdrDateDisplayItem input{
cursor: pointer;
height: 2.5em;
line-height: 2.5em;
border: 0px;
background: transparent;
width: 100%;
color: #849095;
}
.rdrDateDisplayItemActive{
border-color: currentColor;
}
.rdrDateDisplayItemActive input{
color: #7d888d
}
.rdrMonthAndYearWrapper {
align-items: center;
height: 60px;
padding-top: 10px;
}
.rdrMonthAndYearPickers{
font-weight: 600;
}
.rdrMonthAndYearPickers select{
-moz-appearance: none;
appearance: none;
-webkit-appearance: none;
border: 0;
background: transparent;
padding: 10px 30px 10px 10px;
border-radius: 4px;
outline: 0;
color: #3e484f;
background: url("data:image/svg+xml;utf8,<svg width='9px' height='6px' viewBox='0 0 9 6' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><g id='Artboard' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' transform='translate(-636.000000, -171.000000)' fill-opacity='0.368716033'><g id='input' transform='translate(172.000000, 37.000000)' fill='%230E242F' fill-rule='nonzero'><g id='Group-9' transform='translate(323.000000, 127.000000)'><path d='M142.280245,7.23952813 C141.987305,6.92353472 141.512432,6.92361662 141.219585,7.23971106 C140.926739,7.5558055 140.926815,8.06821394 141.219755,8.38420735 L145.498801,13 L149.780245,8.38162071 C150.073185,8.0656273 150.073261,7.55321886 149.780415,7.23712442 C149.487568,6.92102998 149.012695,6.92094808 148.719755,7.23694149 L145.498801,10.7113732 L142.280245,7.23952813 Z' id='arrow'></path></g></g></g></svg>") no-repeat;
background-position: right 8px center;
cursor: pointer;
text-align: center
}
.rdrMonthAndYearPickers select:hover{
background-color: rgba(0,0,0,0.07);
}
.rdrMonthPicker, .rdrYearPicker{
margin: 0 5px
}
.rdrNextPrevButton {
display: block;
width: 24px;
height: 24px;
margin: 0 0.833em;
padding: 0;
border: 0;
border-radius: 5px;
background: #EFF2F7
}
.rdrNextPrevButton:hover{
background: #E1E7F0;
}
.rdrNextPrevButton i {
display: block;
width: 0;
height: 0;
padding: 0;
text-align: center;
border-style: solid;
margin: auto;
transform: translate(-3px, 0px);
}
.rdrPprevButton i {
border-width: 4px 6px 4px 4px;
border-color: transparent rgb(52, 73, 94) transparent transparent;
transform: translate(-3px, 0px);
}
.rdrNextButton i {
margin: 0 0 0 7px;
border-width: 4px 4px 4px 6px;
border-color: transparent transparent transparent rgb(52, 73, 94);
transform: translate(3px, 0px);
}
.rdrWeekDays {
padding: 0 0.833em;
}
.rdrMonth{
padding: 0 0.833em 1.666em 0.833em;
}
.rdrMonth .rdrWeekDays {
padding: 0;
}
.rdrMonths.rdrMonthsVertical .rdrMonth:first-child .rdrMonthName{
display: none;
}
.rdrWeekDay {
font-weight: 400;
line-height: 2.667em;
color: rgb(132, 144, 149);
}
.rdrDay {
background: transparent;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 0;
padding: 0;
line-height: 3.000em;
height: 3.000em;
text-align: center;
color: #1d2429
}
.rdrDay:focus {
outline: 0;
}
.rdrDayNumber {
outline: 0;
font-weight: 300;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
top: 5px;
bottom: 5px;
display: flex;
align-items: center;
justify-content: center;
}
.rdrDayToday .rdrDayNumber span{
font-weight: 500
}
.rdrDayToday .rdrDayNumber span:after{
content: '';
position: absolute;
bottom: 4px;
left: 50%;
transform: translate(-50%, 0);
width: 18px;
height: 2px;
border-radius: 2px;
background: #3d91ff;
}
.rdrDayToday:not(.rdrDayPassive) .rdrInRange ~ .rdrDayNumber span:after,.rdrDayToday:not(.rdrDayPassive) .rdrStartEdge ~ .rdrDayNumber span:after,.rdrDayToday:not(.rdrDayPassive) .rdrEndEdge ~ .rdrDayNumber span:after,.rdrDayToday:not(.rdrDayPassive) .rdrSelected ~ .rdrDayNumber span:after{
background: #fff;
}
.rdrDay:not(.rdrDayPassive) .rdrInRange ~ .rdrDayNumber span,.rdrDay:not(.rdrDayPassive) .rdrStartEdge ~ .rdrDayNumber span,.rdrDay:not(.rdrDayPassive) .rdrEndEdge ~ .rdrDayNumber span,.rdrDay:not(.rdrDayPassive) .rdrSelected ~ .rdrDayNumber span{
color: rgba(255, 255, 255, 0.85);
}
.rdrSelected, .rdrInRange, .rdrStartEdge, .rdrEndEdge{
background: currentColor;
position: absolute;
top: 5px;
left: 0;
right: 0;
bottom: 5px;
}
.rdrSelected{
left: 2px;
right: 2px;
}
.rdrInRange{}
.rdrStartEdge{
border-top-left-radius: 1.042em;
border-bottom-left-radius: 1.042em;
left: 2px;
}
.rdrEndEdge{
border-top-right-radius: 1.042em;
border-bottom-right-radius: 1.042em;
right: 2px;
}
.rdrSelected{
border-radius: 1.042em;
}
.rdrDayStartOfMonth .rdrInRange, .rdrDayStartOfMonth .rdrEndEdge, .rdrDayStartOfWeek .rdrInRange, .rdrDayStartOfWeek .rdrEndEdge{
border-top-left-radius: 1.042em;
border-bottom-left-radius: 1.042em;
left: 2px;
}
.rdrDayEndOfMonth .rdrInRange, .rdrDayEndOfMonth .rdrStartEdge, .rdrDayEndOfWeek .rdrInRange, .rdrDayEndOfWeek .rdrStartEdge{
border-top-right-radius: 1.042em;
border-bottom-right-radius: 1.042em;
right: 2px;
}
.rdrDayStartOfMonth .rdrDayInPreview, .rdrDayStartOfMonth .rdrDayEndPreview, .rdrDayStartOfWeek .rdrDayInPreview, .rdrDayStartOfWeek .rdrDayEndPreview{
border-top-left-radius: 1.333em;
border-bottom-left-radius: 1.333em;
border-left-width: 1px;
left: 0px;
}
.rdrDayEndOfMonth .rdrDayInPreview, .rdrDayEndOfMonth .rdrDayStartPreview, .rdrDayEndOfWeek .rdrDayInPreview, .rdrDayEndOfWeek .rdrDayStartPreview{
border-top-right-radius: 1.333em;
border-bottom-right-radius: 1.333em;
border-right-width: 1px;
right: 0px;
}
.rdrDayStartPreview, .rdrDayInPreview, .rdrDayEndPreview{
background: rgba(255, 255, 255, 0.09);
position: absolute;
top: 3px;
left: 0px;
right: 0px;
bottom: 3px;
pointer-events: none;
border: 0px solid currentColor;
z-index: 1;
}
.rdrDayStartPreview{
border-top-width: 1px;
border-left-width: 1px;
border-bottom-width: 1px;
border-top-left-radius: 1.333em;
border-bottom-left-radius: 1.333em;
left: 0px;
}
.rdrDayInPreview{
border-top-width: 1px;
border-bottom-width: 1px;
}
.rdrDayEndPreview{
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-top-right-radius: 1.333em;
border-bottom-right-radius: 1.333em;
right: 2px;
right: 0px;
}
.rdrDefinedRangesWrapper{
font-size: 12px;
width: 226px;
border-right: solid 1px #eff2f7;
background: #fff;
}
.rdrDefinedRangesWrapper .rdrStaticRangeSelected{
color: currentColor;
font-weight: 600;
}
.rdrStaticRange{
border: 0;
cursor: pointer;
display: block;
outline: 0;
border-bottom: 1px solid #eff2f7;
padding: 0;
background: #fff
}
.rdrStaticRange:hover .rdrStaticRangeLabel,.rdrStaticRange:focus .rdrStaticRangeLabel{
background: #eff2f7;
}
.rdrStaticRangeLabel{
display: block;
outline: 0;
line-height: 18px;
padding: 10px 20px;
text-align: left;
}
.rdrInputRanges{
padding: 10px 0;
}
.rdrInputRange{
align-items: center;
padding: 5px 20px;
}
.rdrInputRangeInput{
width: 30px;
height: 30px;
line-height: 30px;
border-radius: 4px;
text-align: center;
border: solid 1px rgb(222, 231, 235);
margin-right: 10px;
color: rgb(108, 118, 122)
}
.rdrInputRangeInput:focus, .rdrInputRangeInput:hover{
border-color: rgb(180, 191, 196);
outline: 0;
color: #333;
}
.rdrCalendarWrapper:not(.rdrDateRangeWrapper) .rdrDayHovered .rdrDayNumber:after{
content: '';
border: 1px solid currentColor;
border-radius: 1.333em;
position: absolute;
top: -2px;
bottom: -2px;
left: 0px;
right: 0px;
background: transparent;
}
.rdrDayPassive{
pointer-events: none;
}
.rdrDayPassive .rdrDayNumber span{
color: #d5dce0;
}
.rdrDayPassive .rdrInRange, .rdrDayPassive .rdrStartEdge, .rdrDayPassive .rdrEndEdge, .rdrDayPassive .rdrSelected, .rdrDayPassive .rdrDayStartPreview, .rdrDayPassive .rdrDayInPreview, .rdrDayPassive .rdrDayEndPreview{
display: none;
}
.rdrDayDisabled {
background-color: rgb(248, 248, 248);
}
.rdrDayDisabled .rdrDayNumber span{
color: #aeb9bf;
}
.rdrDayDisabled .rdrInRange, .rdrDayDisabled .rdrStartEdge, .rdrDayDisabled .rdrEndEdge, .rdrDayDisabled .rdrSelected, .rdrDayDisabled .rdrDayStartPreview, .rdrDayDisabled .rdrDayInPreview, .rdrDayDisabled .rdrDayEndPreview{
filter: grayscale(100%) opacity(60%);
}
.rdrMonthName{
text-align: left;
font-weight: 600;
color: #849095;
padding: 0.833em;
}
+1 -5
View File
@@ -2,8 +2,4 @@
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
@import "../node_modules/react-date-range/dist/styles.css";
@import "../node_modules/react-date-range/dist/theme/default.css";
@import '@tremor/react/dist/esm/tremor.css';
@import "tailwindcss/utilities";
-6
View File
@@ -5,12 +5,6 @@ volumes:
driver: local
services:
redis:
image: redis:7.0.0-alpine
command: redis-server
restart: always
ports:
- 6379:6379
db:
image: postgres:latest
restart: always
+1 -5
View File
@@ -25,10 +25,6 @@
"docker:db": "docker-compose -f docker-compose.yml up -d",
"docker:db:stop": "docker-compose -f docker-compose.yml down",
"docker:build": "turbo run docker:build",
"docker:build:webapp": "docker build -t apihero-webapp -f ./apps/webapp/Dockerfile .",
"docker:run:webapp": "docker run -it --init --rm -p 3000:3000 --env-file ./apps/webapp/.env --env DATABASE_URL='postgresql://postgres:postgres@db:5432/postgres' --network=app_network apihero-webapp",
"docker:build:logs": "docker build -t apihero-logs -f ./apps/logs/Dockerfile .",
"docker:run:logs": "docker run -it --init --rm -p 3001:3001 --env-file ./apps/logs/.env --env PORT=3001 --env DATABASE_URL='postgresql://postgres:postgres@db:5433/postgres' --network=app_network apihero-logs",
"test": "turbo run test",
"test:dev": "turbo run test:dev",
"start": "turbo run start",
@@ -53,4 +49,4 @@
"turbo": "^1.5.5"
},
"packageManager": "pnpm@7.13.5"
}
}
+12060
View File
File diff suppressed because it is too large Load Diff