-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 73a450e
Showing
51 changed files
with
9,562 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-env node */ | ||
require('@rushstack/eslint-patch/modern-module-resolution') | ||
|
||
module.exports = { | ||
root: true, | ||
extends: [ | ||
'plugin:vue/vue3-essential', | ||
'eslint:recommended', | ||
'@vue/eslint-config-typescript', | ||
'@vue/eslint-config-prettier/skip-formatting' | ||
], | ||
overrides: [ | ||
{ | ||
files: ['cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'], | ||
extends: ['plugin:cypress/recommended'] | ||
} | ||
], | ||
parserOptions: { | ||
ecmaVersion: 'latest' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
coverage | ||
*.local | ||
|
||
/cypress/videos/ | ||
/cypress/screenshots/ | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/prettierrc", | ||
"semi": false, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"printWidth": 100, | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# habit-tracker | ||
|
||
Simple Habit-tracking app. Keep statistics of your good (and bad!) habits! | ||
|
||
## Features | ||
- Typescript | ||
- Vue 3 | ||
- Prisma | ||
- Tailwind | ||
- Vite | ||
|
||
|
||
## Project Setup | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
### Compile and Hot-Reload for Development | ||
|
||
```sh | ||
npm run dev | ||
``` | ||
|
||
## Build css | ||
|
||
```sh | ||
npx tailwindcss -i ./src/input.css -o ./src/assets/output.css --watch | ||
``` | ||
|
||
### Type-Check, Compile and Minify for Production | ||
|
||
```sh | ||
npm run build | ||
``` | ||
|
||
### Run Unit Tests with [Vitest](https://vitest.dev/) | ||
|
||
```sh | ||
npm run test:unit | ||
``` | ||
|
||
### Run End-to-End Tests with [Cypress](https://www.cypress.io/) | ||
|
||
```sh | ||
npm run test:e2e:dev | ||
``` | ||
|
||
```sh | ||
npm run build | ||
npm run test:e2e | ||
``` | ||
|
||
### Lint with [ESLint](https://eslint.org/) | ||
|
||
```sh | ||
npm run lint | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { PrismaClient } from '@prisma/client' | ||
|
||
const prisma = new PrismaClient() | ||
|
||
const getUsers = async () => prisma.user.findMany() | ||
|
||
const getHabits = async () => | ||
prisma.habit.findMany({ | ||
include: { | ||
_count: { | ||
select: { tracks: true } | ||
} | ||
} | ||
}) | ||
|
||
const getHabit = async (id: number) => | ||
prisma.habit.findUnique({ | ||
where: { id }, | ||
include: { | ||
tracks: { | ||
select: { | ||
id: true, | ||
date: true, | ||
habitId: true | ||
} | ||
} | ||
} | ||
}) | ||
|
||
const createHabit = async (title: string, userId: number) => { | ||
const habit = await prisma.habit.create({ | ||
data: { | ||
title, | ||
user: { connect: { id: userId } } | ||
} | ||
}) | ||
|
||
return habit | ||
} | ||
|
||
const deleteHabit = async (id: number) => { | ||
// delete tracks for habit first | ||
await prisma.track.deleteMany({ | ||
where: { | ||
habitId: id | ||
} | ||
}) | ||
|
||
const habit = await prisma.habit.delete({ | ||
where: { id } | ||
}) | ||
|
||
return habit | ||
} | ||
|
||
const getTracks = async () => prisma.track.findMany() | ||
|
||
const addTrack = async (habitId: number) => | ||
prisma.track.create({ | ||
data: { | ||
habitId | ||
} | ||
}) | ||
|
||
export { getUsers, getHabits, getHabit, createHabit, deleteHabit, getTracks, addTrack } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}', | ||
baseUrl: 'http://localhost:4173' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<link | ||
href="https://fonts.googleapis.com/css?family=Poppins:400,700&display=swap" | ||
rel="stylesheet" | ||
/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Habit Tracker</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.