Skip to content

Commit

Permalink
format(api): formatt code
Browse files Browse the repository at this point in the history
  • Loading branch information
huilensolis committed Oct 9, 2024
1 parent 84095d0 commit 4918621
Show file tree
Hide file tree
Showing 11 changed files with 539 additions and 557 deletions.
20 changes: 10 additions & 10 deletions apps/api/src/bin/www.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { app } from "@/app";
import { Environment } from "@/config/environment";

(() => {
const PORT = Environment.PORT;
app.listen(PORT);
const PORT = Environment.PORT;
app.listen(PORT);

console.log(`app running on port ${PORT}`);
console.log(`app running on port ${PORT}`);

if (Environment.NODE_ENV) {
console.log(`running in ${Environment.NODE_ENV} mode`);
} else {
console.log(
"no environment provided on .env file, make sure to set the NODE_ENV variable",
);
}
if (Environment.NODE_ENV) {
console.log(`running in ${Environment.NODE_ENV} mode`);
} else {
console.log(
"no environment provided on .env file, make sure to set the NODE_ENV variable",
);
}
})();
22 changes: 11 additions & 11 deletions apps/api/src/config/database/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ import * as schema from "./schema";
*
*/
async function getDb() {
if (Environment.NODE_ENV === "production") {
// this set up is for supabase datbase, so we disable prepare, since transaction mode doesnt support it
const client = postgres(Environment.DATABASE_URL, { prepare: false });
if (Environment.NODE_ENV === "production") {
// this set up is for supabase datbase, so we disable prepare, since transaction mode doesnt support it
const client = postgres(Environment.DATABASE_URL, { prepare: false });

const db = drizzle<typeof schema>(client, { schema });
const db = drizzle<typeof schema>(client, { schema });

return db;
}
return db;
}

const { POSTGRES_PASSWORD, POSTGRES_USER, POSTGRES_DATABASE } = Environment;
const { POSTGRES_PASSWORD, POSTGRES_USER, POSTGRES_DATABASE } = Environment;

const connectionString = `postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@127.0.0.1:5432/${POSTGRES_DATABASE}`;
const client = postgres(connectionString, { prepare: false });
const connectionString = `postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@127.0.0.1:5432/${POSTGRES_DATABASE}`;
const client = postgres(connectionString, { prepare: false });

const db = drizzle<typeof schema>(client, { schema });
const db = drizzle<typeof schema>(client, { schema });

return db;
return db;
}

const db = await getDb();
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/config/database/custom-types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { customType } from "drizzle-orm/pg-core";

const bytea = customType<{ data: Buffer; notNull: false; default: false }>({
dataType() {
return "bytea";
},
dataType() {
return "bytea";
},
});

export { bytea };
288 changes: 141 additions & 147 deletions apps/api/src/config/database/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,148 +1,142 @@
{
"id": "45a2554d-f7ce-4db6-be5f-0b6d03cda34e",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.entry": {
"name": "entry",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"user_id": {
"name": "user_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "varchar(80)",
"primaryKey": false,
"notNull": true,
"default": "'Untintled'"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"word_count": {
"name": "word_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"content": {
"name": "content",
"type": "json",
"primaryKey": false,
"notNull": false,
"default": "'{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\"}]}'::json"
},
"iv": {
"name": "iv",
"type": "bytea",
"primaryKey": false,
"notNull": false
},
"end_date": {
"name": "end_date",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"entry_user_id_users_id_fk": {
"name": "entry_user_id_users_id_fk",
"tableFrom": "entry",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "cascade"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"name": {
"name": "name",
"type": "varchar(50)",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "varchar(100)",
"primaryKey": false,
"notNull": true
},
"password": {
"name": "password",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"end_date": {
"name": "end_date",
"type": "date",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_email_unique": {
"name": "users_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
"id": "45a2554d-f7ce-4db6-be5f-0b6d03cda34e",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.entry": {
"name": "entry",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"user_id": {
"name": "user_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "varchar(80)",
"primaryKey": false,
"notNull": true,
"default": "'Untintled'"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"word_count": {
"name": "word_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"content": {
"name": "content",
"type": "json",
"primaryKey": false,
"notNull": false,
"default": "'{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\"}]}'::json"
},
"iv": {
"name": "iv",
"type": "bytea",
"primaryKey": false,
"notNull": false
},
"end_date": {
"name": "end_date",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"entry_user_id_users_id_fk": {
"name": "entry_user_id_users_id_fk",
"tableFrom": "entry",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "cascade"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"name": {
"name": "name",
"type": "varchar(50)",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "varchar(100)",
"primaryKey": false,
"notNull": true
},
"password": {
"name": "password",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"end_date": {
"name": "end_date",
"type": "date",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_email_unique": {
"name": "users_email_unique",
"nullsNotDistinct": false,
"columns": ["email"]
}
}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
Loading

0 comments on commit 4918621

Please sign in to comment.