Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a6e8138
refactor(env,auth): update JWKS endpoints
coopbri Mar 30, 2025
16f15b0
chore: format based on default Biome styles
coopbri Mar 30, 2025
f080ca7
feature: add Tiltfile
coopbri Mar 30, 2025
3e6abcd
refactor(plugins): set `plugin.ts` extension
coopbri Mar 30, 2025
d07ca2a
refactor(plugins): set `plugin.ts` extensions
coopbri Mar 30, 2025
640a112
fix(plugins): fix barrel
coopbri Mar 30, 2025
a49ef22
chore: add TODO
coopbri Mar 30, 2025
2be5281
chore: remove unused code
coopbri Mar 30, 2025
8ab5fb7
chore: add TODO
coopbri Mar 30, 2025
3559227
chore: add TODO
coopbri Mar 30, 2025
068e742
refactor(use-auth): handle opaque access token by fetching from OIDC …
coopbri Mar 30, 2025
978be7f
chore: set type import
coopbri Mar 30, 2025
058f9e5
build(deps): upgrade dependencies
coopbri Mar 30, 2025
d64e32a
Merge branch 'master' into feature/hidra-update
coopbri Apr 15, 2025
28180c6
chore: format
coopbri Apr 15, 2025
633eaeb
refactor: extract auth issuer env vars
coopbri Apr 16, 2025
bbfc81e
refactor: change configs file extension
coopbri Apr 16, 2025
047e5c2
fix: fix file extensions
coopbri Apr 17, 2025
e0c7a1e
chore(graphile): update exec schema
coopbri Apr 17, 2025
e0acda8
fix: fix file extensions
coopbri Apr 17, 2025
680e943
chore(env): update TODOs
coopbri Apr 17, 2025
9fa7321
chore(env): remove `AUTH_JWKS_URL`
coopbri Apr 17, 2025
67dabdb
chore(use-auth): update TODOs
coopbri Apr 17, 2025
98130d6
Merge branch 'master' into feature/hidra-update
coopbri Apr 17, 2025
b44f7e6
build(deps): upgrade Graphile dependencies
coopbri Apr 17, 2025
2efd1da
build(scripts): generate and migrate DB before starting
coopbri Apr 18, 2025
e030959
feature: add Dockerfile, .dockerignore
coopbri Apr 18, 2025
4eca0e6
feature(docker): add build step
coopbri Apr 18, 2025
9d1db9f
build(deps): rollback Graphile dependencies
coopbri Apr 18, 2025
237f039
build(scripts): remove DB generation from start script
coopbri Apr 18, 2025
addc1dd
chore: remove Docker
coopbri Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
AUTH_JWKS_URL="https://hidra.omni.dev/realms/test/protocol/openid-connect/certs"
# TODO change once base path changes (https://linear.app/omnidev/issue/OMNI-254/move-apiauth-paths-to-base-path-or-subpath-eg-auth)
AUTH_BASE_URL="https://localhost:8000/api/auth"
3 changes: 2 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
AUTH_JWKS_URL="https://hidra.omni.dev/realms/omni/protocol/openid-connect/certs"
# TODO change once base path changes (https://linear.app/omnidev/issue/OMNI-254/move-apiauth-paths-to-base-path-or-subpath-eg-auth)
AUTH_BASE_URL="https://identity.omni.dev/api/auth"
13 changes: 13 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# load environment variables
load("ext://dotenv", "dotenv")

dotenv(fn=".env.local")

project_name = "backfeed-api"

local_resource(
"install-deps-%s" % project_name,
cmd="bun i",
deps=["package.json"],
labels=[project_name],
)
8 changes: 0 additions & 8 deletions biome.json → biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,5 @@
"noNonNullAssertion": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"arrowParentheses": "always",
"semicolons": "always",
"trailingCommas": "es5"
}
}
}
164 changes: 115 additions & 49 deletions bun.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "drizzle-kit";

import { DATABASE_URL } from "./src/lib/config/env";
import { DATABASE_URL } from "./src/lib/config/env.config";

export default defineConfig({
out: "./src/lib/drizzle/migrations",
Expand Down
2 changes: 1 addition & 1 deletion graphile.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PostGraphileConnectionFilterPreset } from "postgraphile-plugin-connecti
import { makePgService } from "postgraphile/adaptors/pg";
import { PostGraphileAmberPreset } from "postgraphile/presets/amber";

import { DATABASE_URL, isProdEnv } from "./src/lib/config/env";
import { DATABASE_URL, isProdEnv } from "./src/lib/config/env.config";
import {
CommentRBACPlugin,
DownvoteRBACPlugin,
Expand Down
39 changes: 21 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "GRAPHILE_ENV=development NODE_ENV=development bun run --hot src/server.ts",
"build": "bun build --target node --outdir build src/server.ts",
"start": "GRAPHILE_ENV=production NODE_ENV=production bun run build/server.js",
"start": "GRAPHILE_ENV=production NODE_ENV=production bun db:migrate && GRAPHILE_ENV=production NODE_ENV=production bun run build/server.js",
"lint": "biome lint src",
"format": "biome format --write src",
"db:check": "bun --env-file .env.local drizzle-kit check",
Expand All @@ -22,33 +22,36 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@faker-js/faker": "^9.1.0",
"@types/bun": "^1.1.12",
"@types/node": "^22.8.6",
"@types/pg": "^8.11.10",
"drizzle-kit": "^0.30.1",
"husky": "^9.1.6",
"replace-in-file": "^8.2.0",
"typescript": "^5.6.3"
"@faker-js/faker": "^9.6.0",
"@types/bun": "^1.2.8",
"@types/node": "^22.13.14",
"@types/pg": "^8.11.11",
"drizzle-kit": "^0.30.6",
"husky": "^9.1.7",
"replace-in-file": "^8.3.0",
"typescript": "^5.8.2"
},
"dependencies": {
"@envelop/generic-auth": "^8.0.1",
"@envelop/generic-auth": "^9.1.3",
"@envelop/parser-cache": "^8.1.3",
"@envelop/validation-cache": "^8.1.3",
"@escape.tech/graphql-armor": "^3.1.2",
"@graphile/pg-aggregates": "0.2.0-beta.7",
"@graphile/simplify-inflection": "8.0.0-beta.5",
"dayjs": "^1.11.13",
"drizzle-orm": "^0.38.2",
"drizzle-seed": "^0.3.0",
"drizzle-orm": "^0.41.0",
"drizzle-seed": "^0.3.1",
"graphile-export": "0.0.2-beta.24",
"graphql": "^16.9.0",
"graphql-yoga": "^5.8.0",
"hono": "^4.6.8",
"jose": "^5.9.6",
"pg": "^8.13.1",
"graphql": "^16.10.0",
"graphql-yoga": "^5.13.2",
"hono": "^4.7.5",
"jose": "^6.0.10",
"pg": "^8.14.1",
"postgraphile": "5.0.0-beta.37",
"postgraphile-plugin-connection-filter": "3.0.0-beta.7"
},
"trustedDependencies": ["@biomejs/biome", "esbuild"]
"trustedDependencies": [
"@biomejs/biome",
"esbuild"
]
}
26 changes: 13 additions & 13 deletions src/generated/graphql/schema.executable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const spec_downvote = {
}),
description: undefined,
extensions: {
oid: "62509",
oid: "64252",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -228,7 +228,7 @@ const spec_invitation = {
}),
description: undefined,
extensions: {
oid: "62609",
oid: "64351",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -308,7 +308,7 @@ const spec_upvote = {
}),
description: undefined,
extensions: {
oid: "62422",
oid: "64165",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -400,7 +400,7 @@ const spec_comment = {
}),
description: undefined,
extensions: {
oid: "62489",
oid: "64232",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -469,7 +469,7 @@ const spec_organization = {
description: undefined,
codec: TYPES.text,
notNull: true,
hasDefault: true,
hasDefault: false,
extensions: {
tags: {},
canSelect: true,
Expand All @@ -480,7 +480,7 @@ const spec_organization = {
}),
description: undefined,
extensions: {
oid: "62384",
oid: "64127",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -596,7 +596,7 @@ const spec_project = {
}),
description: undefined,
extensions: {
oid: "62408",
oid: "64151",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -724,7 +724,7 @@ const spec_post = {
}),
description: undefined,
extensions: {
oid: "62398",
oid: "64141",
isTableLike: true,
pg: {
serviceName: "main",
Expand All @@ -742,7 +742,7 @@ const roleCodec = enumCodec({
values: ["owner", "admin", "member"],
description: undefined,
extensions: {
oid: "62528",
oid: "64271",
pg: {
serviceName: "main",
schemaName: "public",
Expand Down Expand Up @@ -819,7 +819,7 @@ const spec_member = {
}),
description: undefined,
extensions: {
oid: "62444",
oid: "64187",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -935,7 +935,7 @@ const spec_postStatus = {
}),
description: undefined,
extensions: {
oid: "62583",
oid: "64325",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -1051,7 +1051,7 @@ const spec_user = {
}),
description: undefined,
extensions: {
oid: "62432",
oid: "64175",
isTableLike: true,
pg: {
serviceName: "main",
Expand Down Expand Up @@ -10739,7 +10739,7 @@ input OrganizationInput {
name: String!
createdAt: Datetime
updatedAt: Datetime
slug: String
slug: String!
}

"""The output of our create \`Project\` mutation."""
Expand Down
9 changes: 9 additions & 0 deletions src/lib/config/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Application configuration.
*/
const app = {
name: "Backfeed",
url: "https://backfeed.omni.dev",
};

export default app;
4 changes: 0 additions & 4 deletions src/lib/config/app.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/config/env.ts → src/lib/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const {
// https://stackoverflow.com/a/68578294
HOST = "0.0.0.0",
DATABASE_URL,
AUTH_JWKS_URL,
AUTH_BASE_URL,
} = process.env;

export const isDevEnv = NODE_ENV === "development";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/db/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Client } from "pg";

import { DATABASE_URL } from "lib/config/env";
import { DATABASE_URL } from "lib/config/env.config";

/**
* Postgres database client.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/db/pool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Pool } from "pg";

import { DATABASE_URL } from "lib/config/env";
import { DATABASE_URL } from "lib/config/env.config";

/**
* Postgres database pool.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/comment.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const comments = pgTable(
uniqueIndex().on(table.id),
index().on(table.postId),
index().on(table.userId),
]
],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/downvote.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const downvotes = pgTable(
uniqueIndex().on(table.id),
index().on(table.postId),
index().on(table.userId),
]
],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/invitation.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const invitations = pgTable(
uniqueIndex().on(table.id),
uniqueIndex().on(table.email),
index().on(table.organizationId),
]
],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/member.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const members = pgTable(
uniqueIndex().on(table.id),
index().on(table.userId),
index().on(table.organizationId),
]
],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/organization.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const organizations = pgTable(
createdAt: defaultDate(),
updatedAt: defaultDate(),
},
(table) => [uniqueIndex().on(table.id), uniqueIndex().on(table.slug)]
(table) => [uniqueIndex().on(table.id), uniqueIndex().on(table.slug)],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/post.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const posts = pgTable(
index().on(table.projectId),
index().on(table.userId),
index().on(table.statusId),
]
],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/postStatus.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const postStatuses = pgTable(
uniqueIndex("post_status_unique_id_index").on(table.id),
uniqueIndex().on(table.status, table.projectId),
index().on(table.projectId),
]
],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/project.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const projects = pgTable(
unique().on(table.slug, table.organizationId),
uniqueIndex().on(table.id),
index().on(table.organizationId),
]
],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/upvote.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const upvotes = pgTable(
uniqueIndex().on(table.id),
index().on(table.postId),
index().on(table.userId),
]
],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/drizzle/schema/user.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const users = pgTable(
createdAt: defaultDate(),
updatedAt: defaultDate(),
},
(table) => [uniqueIndex().on(table.id), uniqueIndex().on(table.hidraId)]
(table) => [uniqueIndex().on(table.id), uniqueIndex().on(table.hidraId)],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/envelop/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as useAuth } from "./useAuth";
export { default as useAuth } from "./useAuth.plugin";
Loading