Skip to content

Commit 1e5bf82

Browse files
authored
chore: moving to dynamo / aws
* chore: moving to dynamo... * all queries to dynamo * migrate final code to dynamo * wip - streamining responses * squash * add dist files * remove dist files * run command * debugging; * add email * wip * fix key * update key * update * add deployment * scirpt * env * patch bug
1 parent 2a09d03 commit 1e5bf82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+16523
-24496
lines changed

.env.example

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
OPENAI_API_KEY=
2-
GOOGLE_CLIENT_ID=
3-
GOOGLE_CLIENT_SECRET=
4-
AUTH_ORIGIN=
5-
SECRET=
2+
NUXT_OAUTH_GOOGLE_CLIENT_ID=
3+
NUXT_OAUTH_GOOGLE_CLIENT_SECRET=
4+
NUXT_SESSION_PASSWORD=
5+
NUXT_OAUTH_GITHUB_CLIENT_ID=
6+
NUXT_OAUTH_GITHUB_CLIENT_SECRET=
7+
AWS_ACCESS_KEY_ID=
8+
AWS_SECRET_ACCESS_KEY=
9+
AWS_REGION=

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Nuxt dev/build outputs
2-
.output
32
.data
43
.nuxt
54
.nitro
65
.cache
76
dist
7+
.output
88

99
# Node dependencies
1010
node_modules
@@ -22,3 +22,4 @@ logs
2222
.env
2323
.env.*
2424
!.env.example
25+
*.zip

README.md

+4-74
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,5 @@
1-
# Nuxt 3 Minimal Starter
1+
Running:
22

3-
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
4-
5-
## Setup
6-
7-
Make sure to install the dependencies:
8-
9-
```bash
10-
# npm
11-
npm install
12-
13-
# pnpm
14-
pnpm install
15-
16-
# yarn
17-
yarn install
18-
19-
# bun
20-
bun install
21-
```
22-
23-
## Development Server
24-
25-
Start the development server on `http://localhost:3000`:
26-
27-
```bash
28-
# npm
29-
npm run dev
30-
31-
# pnpm
32-
pnpm run dev
33-
34-
# yarn
35-
yarn dev
36-
37-
# bun
38-
bun run dev
39-
```
40-
41-
## Production
42-
43-
Build the application for production:
44-
45-
```bash
46-
# npm
47-
npm run build
48-
49-
# pnpm
50-
pnpm run build
51-
52-
# yarn
53-
yarn build
54-
55-
# bun
56-
bun run build
57-
```
58-
59-
Locally preview production build:
60-
61-
```bash
62-
# npm
63-
npm run preview
64-
65-
# pnpm
66-
pnpm run preview
67-
68-
# yarn
69-
yarn preview
70-
71-
# bun
72-
bun run preview
73-
```
74-
75-
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
3+
```sh
4+
npx dotenvx run -- node .output/server/index.mjs
5+
```

amplify.yml

-16
This file was deleted.

blah.js

-30
This file was deleted.

components/GithubIcon.vue

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<svg
3+
viewBox="0 0 24 24"
4+
aria-hidden="true"
5+
class="size-6 fill-slate-900"
6+
>
7+
<path
8+
fill-rule="evenodd"
9+
clip-rule="evenodd"
10+
d="M12 2C6.477 2 2 6.463 2 11.97c0 4.404 2.865 8.14 6.839 9.458.5.092.682-.216.682-.48 0-.236-.008-.864-.013-1.695-2.782.602-3.369-1.337-3.369-1.337-.454-1.151-1.11-1.458-1.11-1.458-.908-.618.069-.606.069-.606 1.003.07 1.531 1.027 1.531 1.027.892 1.524 2.341 1.084 2.91.828.092-.643.35-1.083.636-1.332-2.22-.251-4.555-1.107-4.555-4.927 0-1.088.39-1.979 1.029-2.675-.103-.252-.446-1.266.098-2.638 0 0 .84-.268 2.75 1.022A9.607 9.607 0 0 1 12 6.82c.85.004 1.705.114 2.504.336 1.909-1.29 2.747-1.022 2.747-1.022.546 1.372.202 2.386.1 2.638.64.696 1.028 1.587 1.028 2.675 0 3.83-2.339 4.673-4.566 4.92.359.307.678.915.678 1.846 0 1.332-.012 2.407-.012 2.734 0 .267.18.577.688.48 3.97-1.32 6.833-5.054 6.833-9.458C22 6.463 17.522 2 12 2Z"
11+
></path>
12+
</svg>
13+
</template>
14+
15+
<style scoped>
16+
path {
17+
filter: invert(100%);
18+
}
19+
</style>

components/SettingsMenu.vue

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<script setup lang="ts">
2-
const { signOut, data, signIn } = useAuth();
2+
const { user, clear, loggedIn } = useUserSession();
33
4-
const { loading: signingOut, run: handleSignOut } = useLoading(signOut);
4+
const { loading: signingOut, run: handleSignOut } = useLoading(async () => {
5+
await clear();
6+
await navigateTo("/");
7+
});
58
69
const isOpen = ref(false);
710
8-
const link = `https://buy.stripe.com/test_6oE16faCzeD20EM6oo?prefilled_email=${encodeURIComponent(data.value?.user?.email!)}`;
11+
const link = `https://buy.stripe.com/test_6oE16faCzeD20EM6oo?prefilled_email=${encodeURIComponent(user.value?.email)}`;
912
1013
function handleShowPurchaseModal() {
1114
isOpen.value = true;
@@ -14,7 +17,7 @@ function handleShowPurchaseModal() {
1417
1518
async function handleBuy() {
1619
const data = await $fetch("/api/stripe", {
17-
body: JSON.stringify({ amount: 5 }),
20+
body: JSON.stringify({ amount: 5, domain: window.location.href }),
1821
method: "POST",
1922
});
2023
@@ -23,7 +26,7 @@ async function handleBuy() {
2326
}
2427
2528
const items = computed(() => {
26-
if (data.value) {
29+
if (loggedIn.value) {
2730
return [
2831
[
2932
{
@@ -45,7 +48,7 @@ const items = computed(() => {
4548
[
4649
{
4750
label: "Sign up to start studying!",
48-
click: () => signIn("google"),
51+
click: async () => await navigateTo("/auth/google"),
4952
},
5053
],
5154
];

components/SignInGithub.vue

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script setup lang="ts">
2+
//
3+
</script>
4+
5+
<template>
6+
<p class="flex justify-center">
7+
<a href="/auth/github">
8+
<UButton color="black"
9+
><GithubIcon class="h-4 w-4" /> Continue with GitHub</UButton
10+
>
11+
</a>
12+
</p>
13+
</template>

components/SignInGoogle.vue

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<script setup lang="ts">
2-
function handleGoogleAuth() {
3-
signIn("google");
4-
}
5-
6-
const { signIn } = useAuth();
2+
//
73
</script>
84

95
<template>
106
<p class="flex justify-center">
11-
<UButton @click="handleGoogleAuth"
12-
><GoogleIcon class="h-4 w-4" /> Continue with Google</UButton
13-
>
7+
<a href="/auth/google">
8+
<UButton><GoogleIcon class="h-4 w-4" /> Continue with Google</UButton>
9+
</a>
1410
</p>
1511
</template>

composables/createWebSocket.ts

-70
This file was deleted.

ecosystem.config.cjs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
apps: [
3+
{
4+
name: "studyhq",
5+
port: "3000",
6+
exec_mode: "cluster",
7+
instances: "max",
8+
script: "dotenvx run -- node .output/server/index.mjs",
9+
},
10+
],
11+
};

layouts/default.vue

+7-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<script lang="ts" setup>
2-
import { createWebSocket } from "~/composables/createWebSocket";
32
import { emitter } from "~/src/emitter";
43
import { useIntervalFn, useMagicKeys } from "@vueuse/core";
54
const { ctrl, n } = useMagicKeys();
6-
const { data: threads, refresh } = useFetch("/api/threads");
5+
6+
const { data: threads, refresh: refreshThreads } =
7+
await useFetch("/api/threads");
78
89
declare global {
910
interface Window {
1011
ws: WebSocket;
1112
}
1213
}
1314
14-
const { data } = useAuth();
15+
const { loggedIn } = useUserSession();
1516
16-
if (!data.value?.user) {
17+
if (!loggedIn.value) {
1718
await navigateTo("/");
1819
}
1920
20-
const { data: user, refresh: refreshUserData } = useFetch("/api/user");
21+
const { data: user, refresh: refreshUserData } = await useFetch("/api/user");
2122
2223
useIntervalFn(() => {
2324
refreshUserData();
@@ -26,22 +27,7 @@ useIntervalFn(() => {
2627
2728
onMounted(() => {
2829
emitter.on("refresh.exams", refreshExams);
29-
30-
const ws = createWebSocket({
31-
name: "top-level",
32-
});
33-
34-
if (!ws) {
35-
return;
36-
}
37-
38-
window.ws = ws;
39-
40-
registerWebSocketCallback((payload: Payload) => {
41-
if (payload.type === "summary.completed") {
42-
refresh();
43-
}
44-
});
30+
emitter.on("refresh.threads", refreshThreads);
4531
});
4632
4733
const links = computed(() => {

0 commit comments

Comments
 (0)