Skip to content

Commit

Permalink
run deno fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
willianba committed Sep 3, 2024
1 parent dd7d4e7 commit 9c66507
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ expense tracker app I always wanted and never found.

Make sure to install Deno: https://deno.land/manual/getting_started/installation

Then copy the `.env.example` to `.env` and fill the necessary values. You will need a GitHub and a Google apps available for starting the app with authentication.
Then copy the `.env.example` to `.env` and fill the necessary values. You will
need a GitHub and a Google apps available for starting the app with
authentication.

You're good to start the project:

Expand All @@ -19,6 +21,10 @@ This will watch the project directory and restart as necessary.

## Inspecting the DB

Since I used [deno kv](https://deno.com/kv), I didn't find a proper way of inspecting its data, even if I export it to a sqlite file with the `DENO_KV_PATH` environment variable.
Since I used [deno kv](https://deno.com/kv), I didn't find a proper way of
inspecting its data, even if I export it to a sqlite file with the
`DENO_KV_PATH` environment variable.

I found [kview](https://github.com/kitsonk/kview) which works better than inspecting the sqlite file. So, if you intend to run the project locally and want to inspect any db data, I highly encourage to use kview.
I found [kview](https://github.com/kitsonk/kview) which works better than
inspecting the sqlite file. So, if you intend to run the project locally and
want to inspect any db data, I highly encourage to use kview.
8 changes: 5 additions & 3 deletions db/migrations/remove-unnecessary-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ for (const index of indexes) {

const addOperations = kv.atomic();

for await (const entry of kv.list<RawIncome>({
prefix: [oldKey],
})) {
for await (
const entry of kv.list<RawIncome>({
prefix: [oldKey],
})
) {
const income = entry.value;
addOperations.set([newKey, income.userId, income.id], income);
}
Expand Down
17 changes: 3 additions & 14 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"preview": "deno run -A --unstable-kv main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ."
},
"lint": {
"rules": {
"tags": [
"fresh",
"recommended"
]
}
},
"exclude": [
"**/_fresh/*"
],
"lint": { "rules": { "tags": ["fresh", "recommended"] } },
"exclude": ["**/_fresh/*"],
"imports": {
"$fresh/": "https://deno.land/x/[email protected]/",
"@/": "./",
Expand Down Expand Up @@ -54,9 +45,7 @@
},
"deploy": {
"project": "a5faed4e-ddaf-4198-9b02-e379b4f89a5b",
"exclude": [
"**/node_modules"
],
"exclude": ["**/node_modules"],
"include": [],
"entrypoint": "main.ts"
}
Expand Down
10 changes: 5 additions & 5 deletions utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { activeMonth } from "@/signals/menu.ts";
/**
* This function receives a date and returns a string in the format "DD/MM/YYYY"
* It returns the BR format by default. Used to display the date in the tables
**/
*/
export const getFormattedDate = (date: Date | string) => {
// TODO at some point make this come from user settings
return Intl.DateTimeFormat("pt-BR").format(new Date(date));
Expand All @@ -15,7 +15,7 @@ export const getFormattedDate = (date: Date | string) => {
*
* @param {Date} [date] - (optional) Expense or income date to be formatted
* @returns string
**/
*/
export const formDate = (date?: Date) => {
if (!date) {
const d = new Date();
Expand All @@ -34,15 +34,15 @@ export const formDate = (date?: Date) => {

/**
* This function returns the date of today in an object with the year, month and day
**/
*/
export const today = () => {
const date = new Date();
return stripDate(date);
};

/**
* This function receives a date and returns an object with the year, month and day
**/
*/
export const stripDate = (date: Date) => {
const year = date.getFullYear();
const month = date.getMonth() + 1;
Expand All @@ -54,7 +54,7 @@ export const stripDate = (date: Date) => {
/**
* This function receives a date and returns the number of days in that month
* This is a hack. Returning the day 0 will get the last day of the previous month
**/
*/
export const daysInMonth = (month: number, year: number) => {
return new Date(year, month, 0).getDate();
};
12 changes: 5 additions & 7 deletions utils/expenses/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@ export default class ExpenseInputFactory {
}

private getInstallmentDate(installment: number) {
return installment === 1
? new Date(this.data.paymentDate)
: new Date(
new Date(this.data.paymentDate).setMonth(
new Date(this.data.paymentDate).getMonth() + installment - 1,
),
);
return installment === 1 ? new Date(this.data.paymentDate) : new Date(
new Date(this.data.paymentDate).setMonth(
new Date(this.data.paymentDate).getMonth() + installment - 1,
),
);
}
}

0 comments on commit 9c66507

Please sign in to comment.