Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
FROM node:20-alpine
FROM oven/bun:1

RUN npm i -g pnpm

# Install CUPS/AVAHI
RUN apk update --no-cache && apk add --no-cache cups cups-filters avahi inotify-tools
RUN bun install -g pnpm

WORKDIR /app

Expand All@@ -12,15 +9,15 @@ ENV NODE_ENV production
# pnpm fetch does require only lockfile
COPY patches ./patches
COPY pnpm-lock.yaml .npmrc ./
RUN pnpm fetch --prod
RUN bunx pnpm fetch --prod

COPY package.json pnpm-workspace.yaml ./

COPY api/package.json ./api/

# As we're going to deploy, we want only the minimal production dependencies.
# TODO
RUN pnpm install --frozen-lockfile --prod
RUN bunx pnpm install --frozen-lockfile --prod
#RUN --mount=type=cache,target=/root/.pnpm pnpm_CACHE_FOLDER=/root/.pnpm pnpm install --frozen-lockfile --prod

COPY api/dist ./api/dist
Expand All@@ -35,4 +32,4 @@ ARG API_VERSION
ENV API_VERSION=${API_VERSION:-docker_default}
ENV SENTRY_RELEASE=${API_VERSION:-docker_default}

CMD ["pnpm", "start"]
CMD ["bunx", "pnpm", "start"]
7 changes: 4 additions & 3 deletions api/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,12 @@
"test:run": "pnpm run test run --passWithNoTests",
"testsuite": "pnpm circular && pnpm run test:run && pnpm lint",
"dev": "NODE_ENV=development nodemon --signal SIGTERM --exec pnpm dev:vite",
"dev:compiled": "node -r source-map-support/register --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:vite | ../scripts/humanlog.sh",
"start": "pnpm start:compiled",
"dev:compiled": "bun --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:bun | ../scripts/humanlog.sh",
"start": "pnpm start:bun",
"start:compiled": "node -r source-map-support/register ./dist/main.js",
"start:vite": "vite-node ./src/main.ts",
"start:bun": "bun ./src/main.ts",
"ncu": "ncu",
"extract:i18n": "formatjs extract './**/*.ts' --ignore './**/*.d.ts' --format src/i18n/extraction-formatter.cjs --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/i18n/extracted/en.json"
},
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// codegen:start {preset: barrel, include: ./Usecases/*.ts, import: default}
import usecasesBlogControllers from "./Usecases/Blog.Controllers.js"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers.js"
import usecasesMeControllers from "./Usecases/Me.Controllers.js"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers.js"
import usecasesUsersControllers from "./Usecases/Users.Controllers.js"
import usecasesBlogControllers from "./Usecases/Blog.Controllers"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers"
import usecasesMeControllers from "./Usecases/Me.Controllers"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers"
import usecasesUsersControllers from "./Usecases/Users.Controllers"

export {
usecasesBlogControllers,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases/Blog.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
import { matchFor } from "api/lib/matchFor.js"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services"
import { Duration, Effect, Schedule } from "effect"
import { NonNegativeInt } from "effect-app/schema"
import { BlogPost } from "models/Blog.js"
import { BlogRsc } from "resources.js"
import { BogusEvent } from "resources/Events.js"
import { BlogPost } from "models/Blog"
import { BlogRsc } from "resources"
import { BogusEvent } from "resources/Events"

const blog = matchFor(BlogRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/HelloWorld.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { generateFromArbitrary } from "@effect-app/infra/test.arbs"
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { Effect, S } from "effect-app"
import { User } from "models/User.js"
import { HelloWorldRsc } from "resources.js"
import { User } from "models/User"
import { HelloWorldRsc } from "resources"

const helloWorld = matchFor(HelloWorldRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Me.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { MeRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { MeRsc } from "resources"

const me = matchFor(MeRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Operations.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { Operations } from "api/services.js"
import { OperationsRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { Operations } from "api/services"
import { OperationsRsc } from "resources"

const operations = matchFor(OperationsRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/Users.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { ReadonlyArray } from "effect"
import { Order } from "effect-app"
import { UsersRsc } from "resources.js"
import type { UserView } from "resources/Views.js"
import { UsersRsc } from "resources"
import type { UserView } from "resources/Views"

const users = matchFor(UsersRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/_global.ext.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
import type {} from "./services/DBContext.js"
import type {} from "./services/Events.js"
import type {} from "./services/UserProfile.js"
import type {} from "./services/DBContext"
import type {} from "./services/Events"
import type {} from "./services/UserProfile"
14 changes: 7 additions & 7 deletions api/src/api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,16 @@ import { Live as OperationsLive } from "@effect-app/infra/services/Operations/li
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMapContainer"
import { NodeContext } from "@effect/platform-node"
import { all } from "api/routes.js"
import { all } from "api/routes"
import { Effect, Layer, Ref } from "effect-app"
import { GenericTag } from "effect/Context"
import { createServer } from "node:http"
import { MergedConfig } from "./config.js"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http.js"
import * as MW from "./middleware/index.js"
import { RequestContextMiddleware } from "./middleware/index.js"
import { BlogPostRepo, UserRepo } from "./services.js"
import { Events } from "./services/Events.js"
import { MergedConfig } from "./config"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http"
import * as MW from "./middleware/index"
import { RequestContextMiddleware } from "./middleware/index"
import { BlogPostRepo, UserRepo } from "./services"
import { Events } from "./services/Events"

export const devApi = MergedConfig
.andThen((cfg) => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/config.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Config, Effect } from "effect-app"
import { secretURL } from "effect-app/Config/SecretURL"
import * as SecretURL from "effect-app/Config/SecretURL"
import { BaseConfig } from "./baseConfig.js"
import { BaseConfig } from "./baseConfig"

const STORAGE_VERSION = "1"

Expand DownExpand Up@@ -49,7 +49,7 @@ export interface ApiConfig extends ConfigA<typeof ApiConfig> {}

export interface ApiMainConfig extends ApiConfig, BaseConfig {}

export * from "./baseConfig.js"
export * from "./baseConfig"

export const MergedConfig = ApiConfig
.andThen((apiConfig) => BaseConfig.andThen((baseConfig) => ({ ...baseConfig, ...apiConfig })))
Expand Down
10 changes: 5 additions & 5 deletions api/src/lib/RequestEnv.ts
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import { Role } from "models/User.js"
import { Role } from "models/User"

import { HttpServerRequest } from "@effect-app/infra/api/http"
import { JWTError, type RequestHandler } from "@effect-app/infra/api/routing"
import type { RequestContext } from "@effect-app/infra/RequestContext"
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import type { StructFields } from "@effect-app/schema"
import { Req as Req_ } from "@effect-app/schema/REST"
import { NotLoggedInError, UnauthorizedError } from "api/errors.js"
import { Auth0Config, checkJWTI } from "api/middleware/auth.js"
import { NotLoggedInError, UnauthorizedError } from "api/errors"
import { Auth0Config, checkJWTI } from "api/middleware/auth"
import { Duration, Effect, Exit, Layer, Option, Request } from "effect-app"
import {
makeUserProfileFromAuthorizationHeader,
makeUserProfileFromUserHeader,
UserProfile
} from "../services/UserProfile.js"
} from "../services/UserProfile"

// Workaround for the error when using
// import type { AllowAnonymous, RequestConfig } from "resources/lib.js"
// import type { AllowAnonymous, RequestConfig } from "resources/lib"

export type RequestConfig = { allowAnonymous?: true; allowedRoles?: readonly Role[] }

Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/matchFor.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,9 @@ import { defaultErrorHandler, match } from "@effect-app/infra/api/routing"
import { Effect, S } from "effect-app"
import type { SupportedErrors } from "effect-app/client/errors"
import { REST } from "effect-app/schema"
import { handleRequestEnv } from "./RequestEnv.js"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv.js"
import type {} from "resources/lib.js"
import { handleRequestEnv } from "./RequestEnv"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv"
import type {} from "resources/lib"

function handle<
TModule extends Record<
Expand Down
8 changes: 4 additions & 4 deletions api/src/main.ts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import "@effect-app/fluent-extensions"
import { runMain } from "./lib/basicRuntime.js"
import { runMain } from "./lib/basicRuntime"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { faker } from "@faker-js/faker"
import { api, devApi } from "api/api.js"
import { api, devApi } from "api/api"
import { Layer } from "effect-app"
import { setFaker } from "effect-app/faker"
import { MergedConfig } from "./config.js"
import { TracingLive } from "./observability.js"
import { MergedConfig } from "./config"
import { TracingLive } from "./observability"

setFaker(faker)

Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/Middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
import type { NotLoggedInError } from "@effect-app/infra/errors"
import type * as App from "@effect/platform/Http/App"
import type { Effect } from "effect-app"
import * as internal from "./internal/middlewares.js"
import * as internal from "./internal/middlewares"

/**
* Add access logs for handled requests. The log runs before each request.
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/RequestContextMiddleware.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { RequestContext } from "@effect-app/infra/RequestContext"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Effect, S } from "effect-app"
import { RequestId } from "effect-app/ids"
import { NonEmptyString255 } from "effect-app/schema"
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/auth.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable unused-imports/no-unused-vars */
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Config, Effect } from "effect-app"
import {
auth,
Expand Down
6 changes: 3 additions & 3 deletions api/src/middleware/events.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { reportError } from "@effect-app/infra/errorReporter"
import { HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Duration, Effect, S, Schedule, Stream } from "effect-app"
import { ClientEvents } from "resources.js"
import { Events } from "../services/Events.js"
import { ClientEvents } from "resources"
import { Events } from "../services/Events"

export const events = Effect
.gen(function*($) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/health.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http"

export function serverHealth(version: string) {
return HttpRouter.get(
Expand Down
12 changes: 6 additions & 6 deletions api/src/middleware/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./*.ts}
export * from "./auth.js"
export * from "./events.js"
export * from "./health.js"
export * from "./Middlewares.js"
export * from "./openapi.js"
export * from "./RequestContextMiddleware.js"
export * from "./auth"
export * from "./events"
export * from "./health"
export * from "./Middlewares"
export * from "./openapi"
export * from "./RequestContextMiddleware"
// codegen:end
4 changes: 2 additions & 2 deletions api/src/middleware/internal/middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@ import { NotLoggedInError } from "@effect-app/infra/errors"
import * as Middleware from "@effect/platform/Http/Middleware"
import * as ServerRequest from "@effect/platform/Http/ServerRequest"
import * as ServerResponse from "@effect/platform/Http/ServerResponse"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Effect } from "effect-app"
import * as Either from "effect/Either"
import * as FiberRef from "effect/FiberRef"
import { pipe } from "effect/Function"
import * as HashMap from "effect/HashMap"
import * as Metric from "effect/Metric"
import type * as Middlewares from "../Middlewares.js"
import type * as Middlewares from "../Middlewares"

export const accessLog = (level: "Info" | "Warning" | "Debug" = "Info") =>
Middleware.make((app) =>
Expand Down
2 changes: 1 addition & 1 deletion api/src/migrate.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMap
import { StoreMakerLayer } from "@effect-app/infra/services/Store/index"
import * as HttpClientNode from "@effect/platform-node/NodeHttpClient"
import { Layer } from "effect-app"
import { SendgridConfig, StorageConfig } from "./config.js"
import { SendgridConfig, StorageConfig } from "./config"

export const RepoLive = StorageConfig
.andThen(StoreMakerLayer)
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { S } from "effect-app"
import { UserFromId } from "./User.js"
import { UserFromId } from "./User"

export const BlogPostId = S.prefixedStringId<BlogPostId>()("post", "BlogPostId")
export interface BlogPostIdBrand {
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/roles.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Poor man's RBAC

import type { Role } from "./User.js"
import type { Role } from "./User"

/**
* Allow role access
Expand Down
2 changes: 1 addition & 1 deletion api/src/observability.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import {
} from "@sentry/opentelemetry"
import { Effect, Layer, Secret } from "effect-app"
import tcpPortUsed from "tcp-port-used"
import { BaseConfig } from "./config.js"
import { BaseConfig } from "./config"

const appConfig = BaseConfig.runSync

Expand Down
14 changes: 7 additions & 7 deletions api/src/resources.ts
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import "./resources/lib/operations.js"
import "./resources/lib/operations"
import type {} from "@effect/platform/Http/Client"

export { ClientEvents } from "./resources/Events.js"
export { ClientEvents } from "./resources/Events"

// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/_global*.ts, ./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/Views.ts, ./resources/errors.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }}
export * as BlogRsc from "./resources/Blog.js"
export * as HelloWorldRsc from "./resources/HelloWorld.js"
export * as MeRsc from "./resources/Me.js"
export * as OperationsRsc from "./resources/Operations.js"
export * as UsersRsc from "./resources/Users.js"
export * as BlogRsc from "./resources/Blog"
export * as HelloWorldRsc from "./resources/HelloWorld"
export * as MeRsc from "./resources/Me"
export * as OperationsRsc from "./resources/Operations"
export * as UsersRsc from "./resources/Users"
// codegen:end
8 changes: 4 additions & 4 deletions api/src/resources/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./Blog/*.ts, export: { as: 'PascalCase' }, nodir: false }
export * as CreatePost from "./Blog/CreatePost.js"
export * as FindPost from "./Blog/FindPost.js"
export * as GetPosts from "./Blog/GetPosts.js"
export * as PublishPost from "./Blog/PublishPost.js"
export * as CreatePost from "./Blog/CreatePost"
export * as FindPost from "./Blog/FindPost"
export * as GetPosts from "./Blog/GetPosts"
export * as PublishPost from "./Blog/PublishPost"
// codegen:end
// codegen:start {preset: meta, sourcePrefix: src/resources/}
export const meta = { moduleName: "Blog" }
Expand Down
4 changes: 2 additions & 2 deletions api/src/resources/Blog/CreatePost.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { BlogPost, BlogPostId } from "models/Blog.js"
import { S } from "resources/lib.js"
import { BlogPost, BlogPostId } from "models/Blog"
import { S } from "resources/lib"

export class CreatePostRequest extends S.Req({ allowAnonymous: true, allowRoles: ["user"] })<CreatePostRequest>()(
BlogPost.pick("title", "body")
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
FROM node:20-alpine
FROM oven/bun:1

RUN npm i -g pnpm

# Install CUPS/AVAHI
RUN apk update --no-cache && apk add --no-cache cups cups-filters avahi inotify-tools
RUN bun install -g pnpm

WORKDIR /app

Expand All@@ -12,15 +9,15 @@ ENV NODE_ENV production
# pnpm fetch does require only lockfile
COPY patches ./patches
COPY pnpm-lock.yaml .npmrc ./
RUN pnpm fetch --prod
RUN bunx pnpm fetch --prod

COPY package.json pnpm-workspace.yaml ./

COPY api/package.json ./api/

# As we're going to deploy, we want only the minimal production dependencies.
# TODO
RUN pnpm install --frozen-lockfile --prod
RUN bunx pnpm install --frozen-lockfile --prod
#RUN --mount=type=cache,target=/root/.pnpm pnpm_CACHE_FOLDER=/root/.pnpm pnpm install --frozen-lockfile --prod

COPY api/dist ./api/dist
Expand All@@ -35,4 +32,4 @@ ARG API_VERSION
ENV API_VERSION=${API_VERSION:-docker_default}
ENV SENTRY_RELEASE=${API_VERSION:-docker_default}

CMD ["pnpm", "start"]
CMD ["bunx", "pnpm", "start"]
7 changes: 4 additions & 3 deletions api/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,12 @@
"test:run": "pnpm run test run --passWithNoTests",
"testsuite": "pnpm circular && pnpm run test:run && pnpm lint",
"dev": "NODE_ENV=development nodemon --signal SIGTERM --exec pnpm dev:vite",
"dev:compiled": "node -r source-map-support/register --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:vite | ../scripts/humanlog.sh",
"start": "pnpm start:compiled",
"dev:compiled": "bun --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:bun | ../scripts/humanlog.sh",
"start": "pnpm start:bun",
"start:compiled": "node -r source-map-support/register ./dist/main.js",
"start:vite": "vite-node ./src/main.ts",
"start:bun": "bun ./src/main.ts",
"ncu": "ncu",
"extract:i18n": "formatjs extract './**/*.ts' --ignore './**/*.d.ts' --format src/i18n/extraction-formatter.cjs --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/i18n/extracted/en.json"
},
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// codegen:start {preset: barrel, include: ./Usecases/*.ts, import: default}
import usecasesBlogControllers from "./Usecases/Blog.Controllers.js"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers.js"
import usecasesMeControllers from "./Usecases/Me.Controllers.js"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers.js"
import usecasesUsersControllers from "./Usecases/Users.Controllers.js"
import usecasesBlogControllers from "./Usecases/Blog.Controllers"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers"
import usecasesMeControllers from "./Usecases/Me.Controllers"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers"
import usecasesUsersControllers from "./Usecases/Users.Controllers"

export {
usecasesBlogControllers,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases/Blog.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
import { matchFor } from "api/lib/matchFor.js"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services"
import { Duration, Effect, Schedule } from "effect"
import { NonNegativeInt } from "effect-app/schema"
import { BlogPost } from "models/Blog.js"
import { BlogRsc } from "resources.js"
import { BogusEvent } from "resources/Events.js"
import { BlogPost } from "models/Blog"
import { BlogRsc } from "resources"
import { BogusEvent } from "resources/Events"

const blog = matchFor(BlogRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/HelloWorld.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { generateFromArbitrary } from "@effect-app/infra/test.arbs"
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { Effect, S } from "effect-app"
import { User } from "models/User.js"
import { HelloWorldRsc } from "resources.js"
import { User } from "models/User"
import { HelloWorldRsc } from "resources"

const helloWorld = matchFor(HelloWorldRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Me.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { MeRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { MeRsc } from "resources"

const me = matchFor(MeRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Operations.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { Operations } from "api/services.js"
import { OperationsRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { Operations } from "api/services"
import { OperationsRsc } from "resources"

const operations = matchFor(OperationsRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/Users.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { ReadonlyArray } from "effect"
import { Order } from "effect-app"
import { UsersRsc } from "resources.js"
import type { UserView } from "resources/Views.js"
import { UsersRsc } from "resources"
import type { UserView } from "resources/Views"

const users = matchFor(UsersRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/_global.ext.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
import type {} from "./services/DBContext.js"
import type {} from "./services/Events.js"
import type {} from "./services/UserProfile.js"
import type {} from "./services/DBContext"
import type {} from "./services/Events"
import type {} from "./services/UserProfile"
14 changes: 7 additions & 7 deletions api/src/api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,16 @@ import { Live as OperationsLive } from "@effect-app/infra/services/Operations/li
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMapContainer"
import { NodeContext } from "@effect/platform-node"
import { all } from "api/routes.js"
import { all } from "api/routes"
import { Effect, Layer, Ref } from "effect-app"
import { GenericTag } from "effect/Context"
import { createServer } from "node:http"
import { MergedConfig } from "./config.js"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http.js"
import * as MW from "./middleware/index.js"
import { RequestContextMiddleware } from "./middleware/index.js"
import { BlogPostRepo, UserRepo } from "./services.js"
import { Events } from "./services/Events.js"
import { MergedConfig } from "./config"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http"
import * as MW from "./middleware/index"
import { RequestContextMiddleware } from "./middleware/index"
import { BlogPostRepo, UserRepo } from "./services"
import { Events } from "./services/Events"

export const devApi = MergedConfig
.andThen((cfg) => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/config.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Config, Effect } from "effect-app"
import { secretURL } from "effect-app/Config/SecretURL"
import * as SecretURL from "effect-app/Config/SecretURL"
import { BaseConfig } from "./baseConfig.js"
import { BaseConfig } from "./baseConfig"

const STORAGE_VERSION = "1"

Expand DownExpand Up@@ -49,7 +49,7 @@ export interface ApiConfig extends ConfigA<typeof ApiConfig> {}

export interface ApiMainConfig extends ApiConfig, BaseConfig {}

export * from "./baseConfig.js"
export * from "./baseConfig"

export const MergedConfig = ApiConfig
.andThen((apiConfig) => BaseConfig.andThen((baseConfig) => ({ ...baseConfig, ...apiConfig })))
Expand Down
10 changes: 5 additions & 5 deletions api/src/lib/RequestEnv.ts
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import { Role } from "models/User.js"
import { Role } from "models/User"

import { HttpServerRequest } from "@effect-app/infra/api/http"
import { JWTError, type RequestHandler } from "@effect-app/infra/api/routing"
import type { RequestContext } from "@effect-app/infra/RequestContext"
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import type { StructFields } from "@effect-app/schema"
import { Req as Req_ } from "@effect-app/schema/REST"
import { NotLoggedInError, UnauthorizedError } from "api/errors.js"
import { Auth0Config, checkJWTI } from "api/middleware/auth.js"
import { NotLoggedInError, UnauthorizedError } from "api/errors"
import { Auth0Config, checkJWTI } from "api/middleware/auth"
import { Duration, Effect, Exit, Layer, Option, Request } from "effect-app"
import {
makeUserProfileFromAuthorizationHeader,
makeUserProfileFromUserHeader,
UserProfile
} from "../services/UserProfile.js"
} from "../services/UserProfile"

// Workaround for the error when using
// import type { AllowAnonymous, RequestConfig } from "resources/lib.js"
// import type { AllowAnonymous, RequestConfig } from "resources/lib"

export type RequestConfig = { allowAnonymous?: true; allowedRoles?: readonly Role[] }

Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/matchFor.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,9 @@ import { defaultErrorHandler, match } from "@effect-app/infra/api/routing"
import { Effect, S } from "effect-app"
import type { SupportedErrors } from "effect-app/client/errors"
import { REST } from "effect-app/schema"
import { handleRequestEnv } from "./RequestEnv.js"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv.js"
import type {} from "resources/lib.js"
import { handleRequestEnv } from "./RequestEnv"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv"
import type {} from "resources/lib"

function handle<
TModule extends Record<
Expand Down
8 changes: 4 additions & 4 deletions api/src/main.ts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import "@effect-app/fluent-extensions"
import { runMain } from "./lib/basicRuntime.js"
import { runMain } from "./lib/basicRuntime"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { faker } from "@faker-js/faker"
import { api, devApi } from "api/api.js"
import { api, devApi } from "api/api"
import { Layer } from "effect-app"
import { setFaker } from "effect-app/faker"
import { MergedConfig } from "./config.js"
import { TracingLive } from "./observability.js"
import { MergedConfig } from "./config"
import { TracingLive } from "./observability"

setFaker(faker)

Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/Middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
import type { NotLoggedInError } from "@effect-app/infra/errors"
import type * as App from "@effect/platform/Http/App"
import type { Effect } from "effect-app"
import * as internal from "./internal/middlewares.js"
import * as internal from "./internal/middlewares"

/**
* Add access logs for handled requests. The log runs before each request.
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/RequestContextMiddleware.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { RequestContext } from "@effect-app/infra/RequestContext"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Effect, S } from "effect-app"
import { RequestId } from "effect-app/ids"
import { NonEmptyString255 } from "effect-app/schema"
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/auth.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable unused-imports/no-unused-vars */
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Config, Effect } from "effect-app"
import {
auth,
Expand Down
6 changes: 3 additions & 3 deletions api/src/middleware/events.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { reportError } from "@effect-app/infra/errorReporter"
import { HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Duration, Effect, S, Schedule, Stream } from "effect-app"
import { ClientEvents } from "resources.js"
import { Events } from "../services/Events.js"
import { ClientEvents } from "resources"
import { Events } from "../services/Events"

export const events = Effect
.gen(function*($) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/health.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http"

export function serverHealth(version: string) {
return HttpRouter.get(
Expand Down
12 changes: 6 additions & 6 deletions api/src/middleware/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./*.ts}
export * from "./auth.js"
export * from "./events.js"
export * from "./health.js"
export * from "./Middlewares.js"
export * from "./openapi.js"
export * from "./RequestContextMiddleware.js"
export * from "./auth"
export * from "./events"
export * from "./health"
export * from "./Middlewares"
export * from "./openapi"
export * from "./RequestContextMiddleware"
// codegen:end
4 changes: 2 additions & 2 deletions api/src/middleware/internal/middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@ import { NotLoggedInError } from "@effect-app/infra/errors"
import * as Middleware from "@effect/platform/Http/Middleware"
import * as ServerRequest from "@effect/platform/Http/ServerRequest"
import * as ServerResponse from "@effect/platform/Http/ServerResponse"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Effect } from "effect-app"
import * as Either from "effect/Either"
import * as FiberRef from "effect/FiberRef"
import { pipe } from "effect/Function"
import * as HashMap from "effect/HashMap"
import * as Metric from "effect/Metric"
import type * as Middlewares from "../Middlewares.js"
import type * as Middlewares from "../Middlewares"

export const accessLog = (level: "Info" | "Warning" | "Debug" = "Info") =>
Middleware.make((app) =>
Expand Down
2 changes: 1 addition & 1 deletion api/src/migrate.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMap
import { StoreMakerLayer } from "@effect-app/infra/services/Store/index"
import * as HttpClientNode from "@effect/platform-node/NodeHttpClient"
import { Layer } from "effect-app"
import { SendgridConfig, StorageConfig } from "./config.js"
import { SendgridConfig, StorageConfig } from "./config"

export const RepoLive = StorageConfig
.andThen(StoreMakerLayer)
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { S } from "effect-app"
import { UserFromId } from "./User.js"
import { UserFromId } from "./User"

export const BlogPostId = S.prefixedStringId<BlogPostId>()("post", "BlogPostId")
export interface BlogPostIdBrand {
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/roles.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Poor man's RBAC

import type { Role } from "./User.js"
import type { Role } from "./User"

/**
* Allow role access
Expand Down
2 changes: 1 addition & 1 deletion api/src/observability.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import {
} from "@sentry/opentelemetry"
import { Effect, Layer, Secret } from "effect-app"
import tcpPortUsed from "tcp-port-used"
import { BaseConfig } from "./config.js"
import { BaseConfig } from "./config"

const appConfig = BaseConfig.runSync

Expand Down
14 changes: 7 additions & 7 deletions api/src/resources.ts
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import "./resources/lib/operations.js"
import "./resources/lib/operations"
import type {} from "@effect/platform/Http/Client"

export { ClientEvents } from "./resources/Events.js"
export { ClientEvents } from "./resources/Events"

// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/_global*.ts, ./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/Views.ts, ./resources/errors.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }}
export * as BlogRsc from "./resources/Blog.js"
export * as HelloWorldRsc from "./resources/HelloWorld.js"
export * as MeRsc from "./resources/Me.js"
export * as OperationsRsc from "./resources/Operations.js"
export * as UsersRsc from "./resources/Users.js"
export * as BlogRsc from "./resources/Blog"
export * as HelloWorldRsc from "./resources/HelloWorld"
export * as MeRsc from "./resources/Me"
export * as OperationsRsc from "./resources/Operations"
export * as UsersRsc from "./resources/Users"
// codegen:end
8 changes: 4 additions & 4 deletions api/src/resources/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./Blog/*.ts, export: { as: 'PascalCase' }, nodir: false }
export * as CreatePost from "./Blog/CreatePost.js"
export * as FindPost from "./Blog/FindPost.js"
export * as GetPosts from "./Blog/GetPosts.js"
export * as PublishPost from "./Blog/PublishPost.js"
export * as CreatePost from "./Blog/CreatePost"
export * as FindPost from "./Blog/FindPost"
export * as GetPosts from "./Blog/GetPosts"
export * as PublishPost from "./Blog/PublishPost"
// codegen:end
// codegen:start {preset: meta, sourcePrefix: src/resources/}
export const meta = { moduleName: "Blog" }
Expand Down
4 changes: 2 additions & 2 deletions api/src/resources/Blog/CreatePost.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { BlogPost, BlogPostId } from "models/Blog.js"
import { S } from "resources/lib.js"
import { BlogPost, BlogPostId } from "models/Blog"
import { S } from "resources/lib"

export class CreatePostRequest extends S.Req({ allowAnonymous: true, allowRoles: ["user"] })<CreatePostRequest>()(
BlogPost.pick("title", "body")
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
FROM node:20-alpine
FROM oven/bun:1

RUN npm i -g pnpm

# Install CUPS/AVAHI
RUN apk update --no-cache && apk add --no-cache cups cups-filters avahi inotify-tools
RUN bun install -g pnpm

WORKDIR /app

Expand All@@ -12,15 +9,15 @@ ENV NODE_ENV production
# pnpm fetch does require only lockfile
COPY patches ./patches
COPY pnpm-lock.yaml .npmrc ./
RUN pnpm fetch --prod
RUN bunx pnpm fetch --prod

COPY package.json pnpm-workspace.yaml ./

COPY api/package.json ./api/

# As we're going to deploy, we want only the minimal production dependencies.
# TODO
RUN pnpm install --frozen-lockfile --prod
RUN bunx pnpm install --frozen-lockfile --prod
#RUN --mount=type=cache,target=/root/.pnpm pnpm_CACHE_FOLDER=/root/.pnpm pnpm install --frozen-lockfile --prod

COPY api/dist ./api/dist
Expand All@@ -35,4 +32,4 @@ ARG API_VERSION
ENV API_VERSION=${API_VERSION:-docker_default}
ENV SENTRY_RELEASE=${API_VERSION:-docker_default}

CMD ["pnpm", "start"]
CMD ["bunx", "pnpm", "start"]
7 changes: 4 additions & 3 deletions api/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,12 @@
"test:run": "pnpm run test run --passWithNoTests",
"testsuite": "pnpm circular && pnpm run test:run && pnpm lint",
"dev": "NODE_ENV=development nodemon --signal SIGTERM --exec pnpm dev:vite",
"dev:compiled": "node -r source-map-support/register --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:vite | ../scripts/humanlog.sh",
"start": "pnpm start:compiled",
"dev:compiled": "bun --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:bun | ../scripts/humanlog.sh",
"start": "pnpm start:bun",
"start:compiled": "node -r source-map-support/register ./dist/main.js",
"start:vite": "vite-node ./src/main.ts",
"start:bun": "bun ./src/main.ts",
"ncu": "ncu",
"extract:i18n": "formatjs extract './**/*.ts' --ignore './**/*.d.ts' --format src/i18n/extraction-formatter.cjs --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/i18n/extracted/en.json"
},
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// codegen:start {preset: barrel, include: ./Usecases/*.ts, import: default}
import usecasesBlogControllers from "./Usecases/Blog.Controllers.js"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers.js"
import usecasesMeControllers from "./Usecases/Me.Controllers.js"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers.js"
import usecasesUsersControllers from "./Usecases/Users.Controllers.js"
import usecasesBlogControllers from "./Usecases/Blog.Controllers"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers"
import usecasesMeControllers from "./Usecases/Me.Controllers"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers"
import usecasesUsersControllers from "./Usecases/Users.Controllers"

export {
usecasesBlogControllers,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases/Blog.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
import { matchFor } from "api/lib/matchFor.js"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services"
import { Duration, Effect, Schedule } from "effect"
import { NonNegativeInt } from "effect-app/schema"
import { BlogPost } from "models/Blog.js"
import { BlogRsc } from "resources.js"
import { BogusEvent } from "resources/Events.js"
import { BlogPost } from "models/Blog"
import { BlogRsc } from "resources"
import { BogusEvent } from "resources/Events"

const blog = matchFor(BlogRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/HelloWorld.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { generateFromArbitrary } from "@effect-app/infra/test.arbs"
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { Effect, S } from "effect-app"
import { User } from "models/User.js"
import { HelloWorldRsc } from "resources.js"
import { User } from "models/User"
import { HelloWorldRsc } from "resources"

const helloWorld = matchFor(HelloWorldRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Me.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { MeRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { MeRsc } from "resources"

const me = matchFor(MeRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Operations.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { Operations } from "api/services.js"
import { OperationsRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { Operations } from "api/services"
import { OperationsRsc } from "resources"

const operations = matchFor(OperationsRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/Users.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { ReadonlyArray } from "effect"
import { Order } from "effect-app"
import { UsersRsc } from "resources.js"
import type { UserView } from "resources/Views.js"
import { UsersRsc } from "resources"
import type { UserView } from "resources/Views"

const users = matchFor(UsersRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/_global.ext.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
import type {} from "./services/DBContext.js"
import type {} from "./services/Events.js"
import type {} from "./services/UserProfile.js"
import type {} from "./services/DBContext"
import type {} from "./services/Events"
import type {} from "./services/UserProfile"
14 changes: 7 additions & 7 deletions api/src/api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,16 @@ import { Live as OperationsLive } from "@effect-app/infra/services/Operations/li
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMapContainer"
import { NodeContext } from "@effect/platform-node"
import { all } from "api/routes.js"
import { all } from "api/routes"
import { Effect, Layer, Ref } from "effect-app"
import { GenericTag } from "effect/Context"
import { createServer } from "node:http"
import { MergedConfig } from "./config.js"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http.js"
import * as MW from "./middleware/index.js"
import { RequestContextMiddleware } from "./middleware/index.js"
import { BlogPostRepo, UserRepo } from "./services.js"
import { Events } from "./services/Events.js"
import { MergedConfig } from "./config"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http"
import * as MW from "./middleware/index"
import { RequestContextMiddleware } from "./middleware/index"
import { BlogPostRepo, UserRepo } from "./services"
import { Events } from "./services/Events"

export const devApi = MergedConfig
.andThen((cfg) => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/config.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Config, Effect } from "effect-app"
import { secretURL } from "effect-app/Config/SecretURL"
import * as SecretURL from "effect-app/Config/SecretURL"
import { BaseConfig } from "./baseConfig.js"
import { BaseConfig } from "./baseConfig"

const STORAGE_VERSION = "1"

Expand DownExpand Up@@ -49,7 +49,7 @@ export interface ApiConfig extends ConfigA<typeof ApiConfig> {}

export interface ApiMainConfig extends ApiConfig, BaseConfig {}

export * from "./baseConfig.js"
export * from "./baseConfig"

export const MergedConfig = ApiConfig
.andThen((apiConfig) => BaseConfig.andThen((baseConfig) => ({ ...baseConfig, ...apiConfig })))
Expand Down
10 changes: 5 additions & 5 deletions api/src/lib/RequestEnv.ts
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import { Role } from "models/User.js"
import { Role } from "models/User"

import { HttpServerRequest } from "@effect-app/infra/api/http"
import { JWTError, type RequestHandler } from "@effect-app/infra/api/routing"
import type { RequestContext } from "@effect-app/infra/RequestContext"
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import type { StructFields } from "@effect-app/schema"
import { Req as Req_ } from "@effect-app/schema/REST"
import { NotLoggedInError, UnauthorizedError } from "api/errors.js"
import { Auth0Config, checkJWTI } from "api/middleware/auth.js"
import { NotLoggedInError, UnauthorizedError } from "api/errors"
import { Auth0Config, checkJWTI } from "api/middleware/auth"
import { Duration, Effect, Exit, Layer, Option, Request } from "effect-app"
import {
makeUserProfileFromAuthorizationHeader,
makeUserProfileFromUserHeader,
UserProfile
} from "../services/UserProfile.js"
} from "../services/UserProfile"

// Workaround for the error when using
// import type { AllowAnonymous, RequestConfig } from "resources/lib.js"
// import type { AllowAnonymous, RequestConfig } from "resources/lib"

export type RequestConfig = { allowAnonymous?: true; allowedRoles?: readonly Role[] }

Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/matchFor.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,9 @@ import { defaultErrorHandler, match } from "@effect-app/infra/api/routing"
import { Effect, S } from "effect-app"
import type { SupportedErrors } from "effect-app/client/errors"
import { REST } from "effect-app/schema"
import { handleRequestEnv } from "./RequestEnv.js"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv.js"
import type {} from "resources/lib.js"
import { handleRequestEnv } from "./RequestEnv"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv"
import type {} from "resources/lib"

function handle<
TModule extends Record<
Expand Down
8 changes: 4 additions & 4 deletions api/src/main.ts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import "@effect-app/fluent-extensions"
import { runMain } from "./lib/basicRuntime.js"
import { runMain } from "./lib/basicRuntime"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { faker } from "@faker-js/faker"
import { api, devApi } from "api/api.js"
import { api, devApi } from "api/api"
import { Layer } from "effect-app"
import { setFaker } from "effect-app/faker"
import { MergedConfig } from "./config.js"
import { TracingLive } from "./observability.js"
import { MergedConfig } from "./config"
import { TracingLive } from "./observability"

setFaker(faker)

Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/Middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
import type { NotLoggedInError } from "@effect-app/infra/errors"
import type * as App from "@effect/platform/Http/App"
import type { Effect } from "effect-app"
import * as internal from "./internal/middlewares.js"
import * as internal from "./internal/middlewares"

/**
* Add access logs for handled requests. The log runs before each request.
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/RequestContextMiddleware.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { RequestContext } from "@effect-app/infra/RequestContext"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Effect, S } from "effect-app"
import { RequestId } from "effect-app/ids"
import { NonEmptyString255 } from "effect-app/schema"
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/auth.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable unused-imports/no-unused-vars */
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Config, Effect } from "effect-app"
import {
auth,
Expand Down
6 changes: 3 additions & 3 deletions api/src/middleware/events.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { reportError } from "@effect-app/infra/errorReporter"
import { HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Duration, Effect, S, Schedule, Stream } from "effect-app"
import { ClientEvents } from "resources.js"
import { Events } from "../services/Events.js"
import { ClientEvents } from "resources"
import { Events } from "../services/Events"

export const events = Effect
.gen(function*($) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/health.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http"

export function serverHealth(version: string) {
return HttpRouter.get(
Expand Down
12 changes: 6 additions & 6 deletions api/src/middleware/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./*.ts}
export * from "./auth.js"
export * from "./events.js"
export * from "./health.js"
export * from "./Middlewares.js"
export * from "./openapi.js"
export * from "./RequestContextMiddleware.js"
export * from "./auth"
export * from "./events"
export * from "./health"
export * from "./Middlewares"
export * from "./openapi"
export * from "./RequestContextMiddleware"
// codegen:end
4 changes: 2 additions & 2 deletions api/src/middleware/internal/middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@ import { NotLoggedInError } from "@effect-app/infra/errors"
import * as Middleware from "@effect/platform/Http/Middleware"
import * as ServerRequest from "@effect/platform/Http/ServerRequest"
import * as ServerResponse from "@effect/platform/Http/ServerResponse"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Effect } from "effect-app"
import * as Either from "effect/Either"
import * as FiberRef from "effect/FiberRef"
import { pipe } from "effect/Function"
import * as HashMap from "effect/HashMap"
import * as Metric from "effect/Metric"
import type * as Middlewares from "../Middlewares.js"
import type * as Middlewares from "../Middlewares"

export const accessLog = (level: "Info" | "Warning" | "Debug" = "Info") =>
Middleware.make((app) =>
Expand Down
2 changes: 1 addition & 1 deletion api/src/migrate.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMap
import { StoreMakerLayer } from "@effect-app/infra/services/Store/index"
import * as HttpClientNode from "@effect/platform-node/NodeHttpClient"
import { Layer } from "effect-app"
import { SendgridConfig, StorageConfig } from "./config.js"
import { SendgridConfig, StorageConfig } from "./config"

export const RepoLive = StorageConfig
.andThen(StoreMakerLayer)
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { S } from "effect-app"
import { UserFromId } from "./User.js"
import { UserFromId } from "./User"

export const BlogPostId = S.prefixedStringId<BlogPostId>()("post", "BlogPostId")
export interface BlogPostIdBrand {
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/roles.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Poor man's RBAC

import type { Role } from "./User.js"
import type { Role } from "./User"

/**
* Allow role access
Expand Down
2 changes: 1 addition & 1 deletion api/src/observability.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import {
} from "@sentry/opentelemetry"
import { Effect, Layer, Secret } from "effect-app"
import tcpPortUsed from "tcp-port-used"
import { BaseConfig } from "./config.js"
import { BaseConfig } from "./config"

const appConfig = BaseConfig.runSync

Expand Down
14 changes: 7 additions & 7 deletions api/src/resources.ts
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import "./resources/lib/operations.js"
import "./resources/lib/operations"
import type {} from "@effect/platform/Http/Client"

export { ClientEvents } from "./resources/Events.js"
export { ClientEvents } from "./resources/Events"

// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/_global*.ts, ./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/Views.ts, ./resources/errors.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }}
export * as BlogRsc from "./resources/Blog.js"
export * as HelloWorldRsc from "./resources/HelloWorld.js"
export * as MeRsc from "./resources/Me.js"
export * as OperationsRsc from "./resources/Operations.js"
export * as UsersRsc from "./resources/Users.js"
export * as BlogRsc from "./resources/Blog"
export * as HelloWorldRsc from "./resources/HelloWorld"
export * as MeRsc from "./resources/Me"
export * as OperationsRsc from "./resources/Operations"
export * as UsersRsc from "./resources/Users"
// codegen:end
8 changes: 4 additions & 4 deletions api/src/resources/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./Blog/*.ts, export: { as: 'PascalCase' }, nodir: false }
export * as CreatePost from "./Blog/CreatePost.js"
export * as FindPost from "./Blog/FindPost.js"
export * as GetPosts from "./Blog/GetPosts.js"
export * as PublishPost from "./Blog/PublishPost.js"
export * as CreatePost from "./Blog/CreatePost"
export * as FindPost from "./Blog/FindPost"
export * as GetPosts from "./Blog/GetPosts"
export * as PublishPost from "./Blog/PublishPost"
// codegen:end
// codegen:start {preset: meta, sourcePrefix: src/resources/}
export const meta = { moduleName: "Blog" }
Expand Down
4 changes: 2 additions & 2 deletions api/src/resources/Blog/CreatePost.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { BlogPost, BlogPostId } from "models/Blog.js"
import { S } from "resources/lib.js"
import { BlogPost, BlogPostId } from "models/Blog"
import { S } from "resources/lib"

export class CreatePostRequest extends S.Req({ allowAnonymous: true, allowRoles: ["user"] })<CreatePostRequest>()(
BlogPost.pick("title", "body")
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
FROM node:20-alpine
FROM oven/bun:1

RUN npm i -g pnpm

# Install CUPS/AVAHI
RUN apk update --no-cache && apk add --no-cache cups cups-filters avahi inotify-tools
RUN bun install -g pnpm

WORKDIR /app

Expand All@@ -12,15 +9,15 @@ ENV NODE_ENV production
# pnpm fetch does require only lockfile
COPY patches ./patches
COPY pnpm-lock.yaml .npmrc ./
RUN pnpm fetch --prod
RUN bunx pnpm fetch --prod

COPY package.json pnpm-workspace.yaml ./

COPY api/package.json ./api/

# As we're going to deploy, we want only the minimal production dependencies.
# TODO
RUN pnpm install --frozen-lockfile --prod
RUN bunx pnpm install --frozen-lockfile --prod
#RUN --mount=type=cache,target=/root/.pnpm pnpm_CACHE_FOLDER=/root/.pnpm pnpm install --frozen-lockfile --prod

COPY api/dist ./api/dist
Expand All@@ -35,4 +32,4 @@ ARG API_VERSION
ENV API_VERSION=${API_VERSION:-docker_default}
ENV SENTRY_RELEASE=${API_VERSION:-docker_default}

CMD ["pnpm", "start"]
CMD ["bunx", "pnpm", "start"]
7 changes: 4 additions & 3 deletions api/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,12 @@
"test:run": "pnpm run test run --passWithNoTests",
"testsuite": "pnpm circular && pnpm run test:run && pnpm lint",
"dev": "NODE_ENV=development nodemon --signal SIGTERM --exec pnpm dev:vite",
"dev:compiled": "node -r source-map-support/register --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:vite | ../scripts/humanlog.sh",
"start": "pnpm start:compiled",
"dev:compiled": "bun --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:bun | ../scripts/humanlog.sh",
"start": "pnpm start:bun",
"start:compiled": "node -r source-map-support/register ./dist/main.js",
"start:vite": "vite-node ./src/main.ts",
"start:bun": "bun ./src/main.ts",
"ncu": "ncu",
"extract:i18n": "formatjs extract './**/*.ts' --ignore './**/*.d.ts' --format src/i18n/extraction-formatter.cjs --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/i18n/extracted/en.json"
},
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// codegen:start {preset: barrel, include: ./Usecases/*.ts, import: default}
import usecasesBlogControllers from "./Usecases/Blog.Controllers.js"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers.js"
import usecasesMeControllers from "./Usecases/Me.Controllers.js"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers.js"
import usecasesUsersControllers from "./Usecases/Users.Controllers.js"
import usecasesBlogControllers from "./Usecases/Blog.Controllers"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers"
import usecasesMeControllers from "./Usecases/Me.Controllers"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers"
import usecasesUsersControllers from "./Usecases/Users.Controllers"

export {
usecasesBlogControllers,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases/Blog.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
import { matchFor } from "api/lib/matchFor.js"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services"
import { Duration, Effect, Schedule } from "effect"
import { NonNegativeInt } from "effect-app/schema"
import { BlogPost } from "models/Blog.js"
import { BlogRsc } from "resources.js"
import { BogusEvent } from "resources/Events.js"
import { BlogPost } from "models/Blog"
import { BlogRsc } from "resources"
import { BogusEvent } from "resources/Events"

const blog = matchFor(BlogRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/HelloWorld.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { generateFromArbitrary } from "@effect-app/infra/test.arbs"
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { Effect, S } from "effect-app"
import { User } from "models/User.js"
import { HelloWorldRsc } from "resources.js"
import { User } from "models/User"
import { HelloWorldRsc } from "resources"

const helloWorld = matchFor(HelloWorldRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Me.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { MeRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { MeRsc } from "resources"

const me = matchFor(MeRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Operations.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { Operations } from "api/services.js"
import { OperationsRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { Operations } from "api/services"
import { OperationsRsc } from "resources"

const operations = matchFor(OperationsRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/Users.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { ReadonlyArray } from "effect"
import { Order } from "effect-app"
import { UsersRsc } from "resources.js"
import type { UserView } from "resources/Views.js"
import { UsersRsc } from "resources"
import type { UserView } from "resources/Views"

const users = matchFor(UsersRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/_global.ext.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
import type {} from "./services/DBContext.js"
import type {} from "./services/Events.js"
import type {} from "./services/UserProfile.js"
import type {} from "./services/DBContext"
import type {} from "./services/Events"
import type {} from "./services/UserProfile"
14 changes: 7 additions & 7 deletions api/src/api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,16 @@ import { Live as OperationsLive } from "@effect-app/infra/services/Operations/li
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMapContainer"
import { NodeContext } from "@effect/platform-node"
import { all } from "api/routes.js"
import { all } from "api/routes"
import { Effect, Layer, Ref } from "effect-app"
import { GenericTag } from "effect/Context"
import { createServer } from "node:http"
import { MergedConfig } from "./config.js"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http.js"
import * as MW from "./middleware/index.js"
import { RequestContextMiddleware } from "./middleware/index.js"
import { BlogPostRepo, UserRepo } from "./services.js"
import { Events } from "./services/Events.js"
import { MergedConfig } from "./config"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http"
import * as MW from "./middleware/index"
import { RequestContextMiddleware } from "./middleware/index"
import { BlogPostRepo, UserRepo } from "./services"
import { Events } from "./services/Events"

export const devApi = MergedConfig
.andThen((cfg) => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/config.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Config, Effect } from "effect-app"
import { secretURL } from "effect-app/Config/SecretURL"
import * as SecretURL from "effect-app/Config/SecretURL"
import { BaseConfig } from "./baseConfig.js"
import { BaseConfig } from "./baseConfig"

const STORAGE_VERSION = "1"

Expand DownExpand Up@@ -49,7 +49,7 @@ export interface ApiConfig extends ConfigA<typeof ApiConfig> {}

export interface ApiMainConfig extends ApiConfig, BaseConfig {}

export * from "./baseConfig.js"
export * from "./baseConfig"

export const MergedConfig = ApiConfig
.andThen((apiConfig) => BaseConfig.andThen((baseConfig) => ({ ...baseConfig, ...apiConfig })))
Expand Down
10 changes: 5 additions & 5 deletions api/src/lib/RequestEnv.ts
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import { Role } from "models/User.js"
import { Role } from "models/User"

import { HttpServerRequest } from "@effect-app/infra/api/http"
import { JWTError, type RequestHandler } from "@effect-app/infra/api/routing"
import type { RequestContext } from "@effect-app/infra/RequestContext"
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import type { StructFields } from "@effect-app/schema"
import { Req as Req_ } from "@effect-app/schema/REST"
import { NotLoggedInError, UnauthorizedError } from "api/errors.js"
import { Auth0Config, checkJWTI } from "api/middleware/auth.js"
import { NotLoggedInError, UnauthorizedError } from "api/errors"
import { Auth0Config, checkJWTI } from "api/middleware/auth"
import { Duration, Effect, Exit, Layer, Option, Request } from "effect-app"
import {
makeUserProfileFromAuthorizationHeader,
makeUserProfileFromUserHeader,
UserProfile
} from "../services/UserProfile.js"
} from "../services/UserProfile"

// Workaround for the error when using
// import type { AllowAnonymous, RequestConfig } from "resources/lib.js"
// import type { AllowAnonymous, RequestConfig } from "resources/lib"

export type RequestConfig = { allowAnonymous?: true; allowedRoles?: readonly Role[] }

Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/matchFor.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,9 @@ import { defaultErrorHandler, match } from "@effect-app/infra/api/routing"
import { Effect, S } from "effect-app"
import type { SupportedErrors } from "effect-app/client/errors"
import { REST } from "effect-app/schema"
import { handleRequestEnv } from "./RequestEnv.js"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv.js"
import type {} from "resources/lib.js"
import { handleRequestEnv } from "./RequestEnv"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv"
import type {} from "resources/lib"

function handle<
TModule extends Record<
Expand Down
8 changes: 4 additions & 4 deletions api/src/main.ts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import "@effect-app/fluent-extensions"
import { runMain } from "./lib/basicRuntime.js"
import { runMain } from "./lib/basicRuntime"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { faker } from "@faker-js/faker"
import { api, devApi } from "api/api.js"
import { api, devApi } from "api/api"
import { Layer } from "effect-app"
import { setFaker } from "effect-app/faker"
import { MergedConfig } from "./config.js"
import { TracingLive } from "./observability.js"
import { MergedConfig } from "./config"
import { TracingLive } from "./observability"

setFaker(faker)

Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/Middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
import type { NotLoggedInError } from "@effect-app/infra/errors"
import type * as App from "@effect/platform/Http/App"
import type { Effect } from "effect-app"
import * as internal from "./internal/middlewares.js"
import * as internal from "./internal/middlewares"

/**
* Add access logs for handled requests. The log runs before each request.
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/RequestContextMiddleware.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { RequestContext } from "@effect-app/infra/RequestContext"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Effect, S } from "effect-app"
import { RequestId } from "effect-app/ids"
import { NonEmptyString255 } from "effect-app/schema"
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/auth.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable unused-imports/no-unused-vars */
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Config, Effect } from "effect-app"
import {
auth,
Expand Down
6 changes: 3 additions & 3 deletions api/src/middleware/events.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { reportError } from "@effect-app/infra/errorReporter"
import { HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Duration, Effect, S, Schedule, Stream } from "effect-app"
import { ClientEvents } from "resources.js"
import { Events } from "../services/Events.js"
import { ClientEvents } from "resources"
import { Events } from "../services/Events"

export const events = Effect
.gen(function*($) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/health.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http"

export function serverHealth(version: string) {
return HttpRouter.get(
Expand Down
12 changes: 6 additions & 6 deletions api/src/middleware/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./*.ts}
export * from "./auth.js"
export * from "./events.js"
export * from "./health.js"
export * from "./Middlewares.js"
export * from "./openapi.js"
export * from "./RequestContextMiddleware.js"
export * from "./auth"
export * from "./events"
export * from "./health"
export * from "./Middlewares"
export * from "./openapi"
export * from "./RequestContextMiddleware"
// codegen:end
4 changes: 2 additions & 2 deletions api/src/middleware/internal/middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@ import { NotLoggedInError } from "@effect-app/infra/errors"
import * as Middleware from "@effect/platform/Http/Middleware"
import * as ServerRequest from "@effect/platform/Http/ServerRequest"
import * as ServerResponse from "@effect/platform/Http/ServerResponse"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Effect } from "effect-app"
import * as Either from "effect/Either"
import * as FiberRef from "effect/FiberRef"
import { pipe } from "effect/Function"
import * as HashMap from "effect/HashMap"
import * as Metric from "effect/Metric"
import type * as Middlewares from "../Middlewares.js"
import type * as Middlewares from "../Middlewares"

export const accessLog = (level: "Info" | "Warning" | "Debug" = "Info") =>
Middleware.make((app) =>
Expand Down
2 changes: 1 addition & 1 deletion api/src/migrate.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMap
import { StoreMakerLayer } from "@effect-app/infra/services/Store/index"
import * as HttpClientNode from "@effect/platform-node/NodeHttpClient"
import { Layer } from "effect-app"
import { SendgridConfig, StorageConfig } from "./config.js"
import { SendgridConfig, StorageConfig } from "./config"

export const RepoLive = StorageConfig
.andThen(StoreMakerLayer)
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { S } from "effect-app"
import { UserFromId } from "./User.js"
import { UserFromId } from "./User"

export const BlogPostId = S.prefixedStringId<BlogPostId>()("post", "BlogPostId")
export interface BlogPostIdBrand {
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/roles.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Poor man's RBAC

import type { Role } from "./User.js"
import type { Role } from "./User"

/**
* Allow role access
Expand Down
2 changes: 1 addition & 1 deletion api/src/observability.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import {
} from "@sentry/opentelemetry"
import { Effect, Layer, Secret } from "effect-app"
import tcpPortUsed from "tcp-port-used"
import { BaseConfig } from "./config.js"
import { BaseConfig } from "./config"

const appConfig = BaseConfig.runSync

Expand Down
14 changes: 7 additions & 7 deletions api/src/resources.ts
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import "./resources/lib/operations.js"
import "./resources/lib/operations"
import type {} from "@effect/platform/Http/Client"

export { ClientEvents } from "./resources/Events.js"
export { ClientEvents } from "./resources/Events"

// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/_global*.ts, ./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/Views.ts, ./resources/errors.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }}
export * as BlogRsc from "./resources/Blog.js"
export * as HelloWorldRsc from "./resources/HelloWorld.js"
export * as MeRsc from "./resources/Me.js"
export * as OperationsRsc from "./resources/Operations.js"
export * as UsersRsc from "./resources/Users.js"
export * as BlogRsc from "./resources/Blog"
export * as HelloWorldRsc from "./resources/HelloWorld"
export * as MeRsc from "./resources/Me"
export * as OperationsRsc from "./resources/Operations"
export * as UsersRsc from "./resources/Users"
// codegen:end
8 changes: 4 additions & 4 deletions api/src/resources/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./Blog/*.ts, export: { as: 'PascalCase' }, nodir: false }
export * as CreatePost from "./Blog/CreatePost.js"
export * as FindPost from "./Blog/FindPost.js"
export * as GetPosts from "./Blog/GetPosts.js"
export * as PublishPost from "./Blog/PublishPost.js"
export * as CreatePost from "./Blog/CreatePost"
export * as FindPost from "./Blog/FindPost"
export * as GetPosts from "./Blog/GetPosts"
export * as PublishPost from "./Blog/PublishPost"
// codegen:end
// codegen:start {preset: meta, sourcePrefix: src/resources/}
export const meta = { moduleName: "Blog" }
Expand Down
4 changes: 2 additions & 2 deletions api/src/resources/Blog/CreatePost.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { BlogPost, BlogPostId } from "models/Blog.js"
import { S } from "resources/lib.js"
import { BlogPost, BlogPostId } from "models/Blog"
import { S } from "resources/lib"

export class CreatePostRequest extends S.Req({ allowAnonymous: true, allowRoles: ["user"] })<CreatePostRequest>()(
BlogPost.pick("title", "body")
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
FROM node:20-alpine
FROM oven/bun:1

RUN npm i -g pnpm

# Install CUPS/AVAHI
RUN apk update --no-cache && apk add --no-cache cups cups-filters avahi inotify-tools
RUN bun install -g pnpm

WORKDIR /app

Expand All@@ -12,15 +9,15 @@ ENV NODE_ENV production
# pnpm fetch does require only lockfile
COPY patches ./patches
COPY pnpm-lock.yaml .npmrc ./
RUN pnpm fetch --prod
RUN bunx pnpm fetch --prod

COPY package.json pnpm-workspace.yaml ./

COPY api/package.json ./api/

# As we're going to deploy, we want only the minimal production dependencies.
# TODO
RUN pnpm install --frozen-lockfile --prod
RUN bunx pnpm install --frozen-lockfile --prod
#RUN --mount=type=cache,target=/root/.pnpm pnpm_CACHE_FOLDER=/root/.pnpm pnpm install --frozen-lockfile --prod

COPY api/dist ./api/dist
Expand All@@ -35,4 +32,4 @@ ARG API_VERSION
ENV API_VERSION=${API_VERSION:-docker_default}
ENV SENTRY_RELEASE=${API_VERSION:-docker_default}

CMD ["pnpm", "start"]
CMD ["bunx", "pnpm", "start"]
7 changes: 4 additions & 3 deletions api/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,12 @@
"test:run": "pnpm run test run --passWithNoTests",
"testsuite": "pnpm circular && pnpm run test:run && pnpm lint",
"dev": "NODE_ENV=development nodemon --signal SIGTERM --exec pnpm dev:vite",
"dev:compiled": "node -r source-map-support/register --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:vite | ../scripts/humanlog.sh",
"start": "pnpm start:compiled",
"dev:compiled": "bun --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:bun | ../scripts/humanlog.sh",
"start": "pnpm start:bun",
"start:compiled": "node -r source-map-support/register ./dist/main.js",
"start:vite": "vite-node ./src/main.ts",
"start:bun": "bun ./src/main.ts",
"ncu": "ncu",
"extract:i18n": "formatjs extract './**/*.ts' --ignore './**/*.d.ts' --format src/i18n/extraction-formatter.cjs --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/i18n/extracted/en.json"
},
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// codegen:start {preset: barrel, include: ./Usecases/*.ts, import: default}
import usecasesBlogControllers from "./Usecases/Blog.Controllers.js"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers.js"
import usecasesMeControllers from "./Usecases/Me.Controllers.js"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers.js"
import usecasesUsersControllers from "./Usecases/Users.Controllers.js"
import usecasesBlogControllers from "./Usecases/Blog.Controllers"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers"
import usecasesMeControllers from "./Usecases/Me.Controllers"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers"
import usecasesUsersControllers from "./Usecases/Users.Controllers"

export {
usecasesBlogControllers,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases/Blog.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
import { matchFor } from "api/lib/matchFor.js"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services"
import { Duration, Effect, Schedule } from "effect"
import { NonNegativeInt } from "effect-app/schema"
import { BlogPost } from "models/Blog.js"
import { BlogRsc } from "resources.js"
import { BogusEvent } from "resources/Events.js"
import { BlogPost } from "models/Blog"
import { BlogRsc } from "resources"
import { BogusEvent } from "resources/Events"

const blog = matchFor(BlogRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/HelloWorld.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { generateFromArbitrary } from "@effect-app/infra/test.arbs"
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { Effect, S } from "effect-app"
import { User } from "models/User.js"
import { HelloWorldRsc } from "resources.js"
import { User } from "models/User"
import { HelloWorldRsc } from "resources"

const helloWorld = matchFor(HelloWorldRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Me.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { MeRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { MeRsc } from "resources"

const me = matchFor(MeRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Operations.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { Operations } from "api/services.js"
import { OperationsRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { Operations } from "api/services"
import { OperationsRsc } from "resources"

const operations = matchFor(OperationsRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/Users.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { ReadonlyArray } from "effect"
import { Order } from "effect-app"
import { UsersRsc } from "resources.js"
import type { UserView } from "resources/Views.js"
import { UsersRsc } from "resources"
import type { UserView } from "resources/Views"

const users = matchFor(UsersRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/_global.ext.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
import type {} from "./services/DBContext.js"
import type {} from "./services/Events.js"
import type {} from "./services/UserProfile.js"
import type {} from "./services/DBContext"
import type {} from "./services/Events"
import type {} from "./services/UserProfile"
14 changes: 7 additions & 7 deletions api/src/api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,16 @@ import { Live as OperationsLive } from "@effect-app/infra/services/Operations/li
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMapContainer"
import { NodeContext } from "@effect/platform-node"
import { all } from "api/routes.js"
import { all } from "api/routes"
import { Effect, Layer, Ref } from "effect-app"
import { GenericTag } from "effect/Context"
import { createServer } from "node:http"
import { MergedConfig } from "./config.js"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http.js"
import * as MW from "./middleware/index.js"
import { RequestContextMiddleware } from "./middleware/index.js"
import { BlogPostRepo, UserRepo } from "./services.js"
import { Events } from "./services/Events.js"
import { MergedConfig } from "./config"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http"
import * as MW from "./middleware/index"
import { RequestContextMiddleware } from "./middleware/index"
import { BlogPostRepo, UserRepo } from "./services"
import { Events } from "./services/Events"

export const devApi = MergedConfig
.andThen((cfg) => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/config.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Config, Effect } from "effect-app"
import { secretURL } from "effect-app/Config/SecretURL"
import * as SecretURL from "effect-app/Config/SecretURL"
import { BaseConfig } from "./baseConfig.js"
import { BaseConfig } from "./baseConfig"

const STORAGE_VERSION = "1"

Expand DownExpand Up@@ -49,7 +49,7 @@ export interface ApiConfig extends ConfigA<typeof ApiConfig> {}

export interface ApiMainConfig extends ApiConfig, BaseConfig {}

export * from "./baseConfig.js"
export * from "./baseConfig"

export const MergedConfig = ApiConfig
.andThen((apiConfig) => BaseConfig.andThen((baseConfig) => ({ ...baseConfig, ...apiConfig })))
Expand Down
10 changes: 5 additions & 5 deletions api/src/lib/RequestEnv.ts
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import { Role } from "models/User.js"
import { Role } from "models/User"

import { HttpServerRequest } from "@effect-app/infra/api/http"
import { JWTError, type RequestHandler } from "@effect-app/infra/api/routing"
import type { RequestContext } from "@effect-app/infra/RequestContext"
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import type { StructFields } from "@effect-app/schema"
import { Req as Req_ } from "@effect-app/schema/REST"
import { NotLoggedInError, UnauthorizedError } from "api/errors.js"
import { Auth0Config, checkJWTI } from "api/middleware/auth.js"
import { NotLoggedInError, UnauthorizedError } from "api/errors"
import { Auth0Config, checkJWTI } from "api/middleware/auth"
import { Duration, Effect, Exit, Layer, Option, Request } from "effect-app"
import {
makeUserProfileFromAuthorizationHeader,
makeUserProfileFromUserHeader,
UserProfile
} from "../services/UserProfile.js"
} from "../services/UserProfile"

// Workaround for the error when using
// import type { AllowAnonymous, RequestConfig } from "resources/lib.js"
// import type { AllowAnonymous, RequestConfig } from "resources/lib"

export type RequestConfig = { allowAnonymous?: true; allowedRoles?: readonly Role[] }

Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/matchFor.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,9 @@ import { defaultErrorHandler, match } from "@effect-app/infra/api/routing"
import { Effect, S } from "effect-app"
import type { SupportedErrors } from "effect-app/client/errors"
import { REST } from "effect-app/schema"
import { handleRequestEnv } from "./RequestEnv.js"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv.js"
import type {} from "resources/lib.js"
import { handleRequestEnv } from "./RequestEnv"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv"
import type {} from "resources/lib"

function handle<
TModule extends Record<
Expand Down
8 changes: 4 additions & 4 deletions api/src/main.ts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import "@effect-app/fluent-extensions"
import { runMain } from "./lib/basicRuntime.js"
import { runMain } from "./lib/basicRuntime"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { faker } from "@faker-js/faker"
import { api, devApi } from "api/api.js"
import { api, devApi } from "api/api"
import { Layer } from "effect-app"
import { setFaker } from "effect-app/faker"
import { MergedConfig } from "./config.js"
import { TracingLive } from "./observability.js"
import { MergedConfig } from "./config"
import { TracingLive } from "./observability"

setFaker(faker)

Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/Middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
import type { NotLoggedInError } from "@effect-app/infra/errors"
import type * as App from "@effect/platform/Http/App"
import type { Effect } from "effect-app"
import * as internal from "./internal/middlewares.js"
import * as internal from "./internal/middlewares"

/**
* Add access logs for handled requests. The log runs before each request.
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/RequestContextMiddleware.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { RequestContext } from "@effect-app/infra/RequestContext"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Effect, S } from "effect-app"
import { RequestId } from "effect-app/ids"
import { NonEmptyString255 } from "effect-app/schema"
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/auth.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable unused-imports/no-unused-vars */
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Config, Effect } from "effect-app"
import {
auth,
Expand Down
6 changes: 3 additions & 3 deletions api/src/middleware/events.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { reportError } from "@effect-app/infra/errorReporter"
import { HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Duration, Effect, S, Schedule, Stream } from "effect-app"
import { ClientEvents } from "resources.js"
import { Events } from "../services/Events.js"
import { ClientEvents } from "resources"
import { Events } from "../services/Events"

export const events = Effect
.gen(function*($) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/health.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http"

export function serverHealth(version: string) {
return HttpRouter.get(
Expand Down
12 changes: 6 additions & 6 deletions api/src/middleware/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./*.ts}
export * from "./auth.js"
export * from "./events.js"
export * from "./health.js"
export * from "./Middlewares.js"
export * from "./openapi.js"
export * from "./RequestContextMiddleware.js"
export * from "./auth"
export * from "./events"
export * from "./health"
export * from "./Middlewares"
export * from "./openapi"
export * from "./RequestContextMiddleware"
// codegen:end
4 changes: 2 additions & 2 deletions api/src/middleware/internal/middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@ import { NotLoggedInError } from "@effect-app/infra/errors"
import * as Middleware from "@effect/platform/Http/Middleware"
import * as ServerRequest from "@effect/platform/Http/ServerRequest"
import * as ServerResponse from "@effect/platform/Http/ServerResponse"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Effect } from "effect-app"
import * as Either from "effect/Either"
import * as FiberRef from "effect/FiberRef"
import { pipe } from "effect/Function"
import * as HashMap from "effect/HashMap"
import * as Metric from "effect/Metric"
import type * as Middlewares from "../Middlewares.js"
import type * as Middlewares from "../Middlewares"

export const accessLog = (level: "Info" | "Warning" | "Debug" = "Info") =>
Middleware.make((app) =>
Expand Down
2 changes: 1 addition & 1 deletion api/src/migrate.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMap
import { StoreMakerLayer } from "@effect-app/infra/services/Store/index"
import * as HttpClientNode from "@effect/platform-node/NodeHttpClient"
import { Layer } from "effect-app"
import { SendgridConfig, StorageConfig } from "./config.js"
import { SendgridConfig, StorageConfig } from "./config"

export const RepoLive = StorageConfig
.andThen(StoreMakerLayer)
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { S } from "effect-app"
import { UserFromId } from "./User.js"
import { UserFromId } from "./User"

export const BlogPostId = S.prefixedStringId<BlogPostId>()("post", "BlogPostId")
export interface BlogPostIdBrand {
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/roles.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Poor man's RBAC

import type { Role } from "./User.js"
import type { Role } from "./User"

/**
* Allow role access
Expand Down
2 changes: 1 addition & 1 deletion api/src/observability.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import {
} from "@sentry/opentelemetry"
import { Effect, Layer, Secret } from "effect-app"
import tcpPortUsed from "tcp-port-used"
import { BaseConfig } from "./config.js"
import { BaseConfig } from "./config"

const appConfig = BaseConfig.runSync

Expand Down
14 changes: 7 additions & 7 deletions api/src/resources.ts
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import "./resources/lib/operations.js"
import "./resources/lib/operations"
import type {} from "@effect/platform/Http/Client"

export { ClientEvents } from "./resources/Events.js"
export { ClientEvents } from "./resources/Events"

// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/_global*.ts, ./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/Views.ts, ./resources/errors.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }}
export * as BlogRsc from "./resources/Blog.js"
export * as HelloWorldRsc from "./resources/HelloWorld.js"
export * as MeRsc from "./resources/Me.js"
export * as OperationsRsc from "./resources/Operations.js"
export * as UsersRsc from "./resources/Users.js"
export * as BlogRsc from "./resources/Blog"
export * as HelloWorldRsc from "./resources/HelloWorld"
export * as MeRsc from "./resources/Me"
export * as OperationsRsc from "./resources/Operations"
export * as UsersRsc from "./resources/Users"
// codegen:end
8 changes: 4 additions & 4 deletions api/src/resources/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./Blog/*.ts, export: { as: 'PascalCase' }, nodir: false }
export * as CreatePost from "./Blog/CreatePost.js"
export * as FindPost from "./Blog/FindPost.js"
export * as GetPosts from "./Blog/GetPosts.js"
export * as PublishPost from "./Blog/PublishPost.js"
export * as CreatePost from "./Blog/CreatePost"
export * as FindPost from "./Blog/FindPost"
export * as GetPosts from "./Blog/GetPosts"
export * as PublishPost from "./Blog/PublishPost"
// codegen:end
// codegen:start {preset: meta, sourcePrefix: src/resources/}
export const meta = { moduleName: "Blog" }
Expand Down
4 changes: 2 additions & 2 deletions api/src/resources/Blog/CreatePost.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { BlogPost, BlogPostId } from "models/Blog.js"
import { S } from "resources/lib.js"
import { BlogPost, BlogPostId } from "models/Blog"
import { S } from "resources/lib"

export class CreatePostRequest extends S.Req({ allowAnonymous: true, allowRoles: ["user"] })<CreatePostRequest>()(
BlogPost.pick("title", "body")
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
FROM node:20-alpine
FROM oven/bun:1

RUN npm i -g pnpm

# Install CUPS/AVAHI
RUN apk update --no-cache && apk add --no-cache cups cups-filters avahi inotify-tools
RUN bun install -g pnpm

WORKDIR /app

Expand All@@ -12,15 +9,15 @@ ENV NODE_ENV production
# pnpm fetch does require only lockfile
COPY patches ./patches
COPY pnpm-lock.yaml .npmrc ./
RUN pnpm fetch --prod
RUN bunx pnpm fetch --prod

COPY package.json pnpm-workspace.yaml ./

COPY api/package.json ./api/

# As we're going to deploy, we want only the minimal production dependencies.
# TODO
RUN pnpm install --frozen-lockfile --prod
RUN bunx pnpm install --frozen-lockfile --prod
#RUN --mount=type=cache,target=/root/.pnpm pnpm_CACHE_FOLDER=/root/.pnpm pnpm install --frozen-lockfile --prod

COPY api/dist ./api/dist
Expand All@@ -35,4 +32,4 @@ ARG API_VERSION
ENV API_VERSION=${API_VERSION:-docker_default}
ENV SENTRY_RELEASE=${API_VERSION:-docker_default}

CMD ["pnpm", "start"]
CMD ["bunx", "pnpm", "start"]
7 changes: 4 additions & 3 deletions api/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,12 @@
"test:run": "pnpm run test run --passWithNoTests",
"testsuite": "pnpm circular && pnpm run test:run && pnpm lint",
"dev": "NODE_ENV=development nodemon --signal SIGTERM --exec pnpm dev:vite",
"dev:compiled": "node -r source-map-support/register --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:vite | ../scripts/humanlog.sh",
"start": "pnpm start:compiled",
"dev:compiled": "bun --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:bun | ../scripts/humanlog.sh",
"start": "pnpm start:bun",
"start:compiled": "node -r source-map-support/register ./dist/main.js",
"start:vite": "vite-node ./src/main.ts",
"start:bun": "bun ./src/main.ts",
"ncu": "ncu",
"extract:i18n": "formatjs extract './**/*.ts' --ignore './**/*.d.ts' --format src/i18n/extraction-formatter.cjs --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/i18n/extracted/en.json"
},
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// codegen:start {preset: barrel, include: ./Usecases/*.ts, import: default}
import usecasesBlogControllers from "./Usecases/Blog.Controllers.js"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers.js"
import usecasesMeControllers from "./Usecases/Me.Controllers.js"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers.js"
import usecasesUsersControllers from "./Usecases/Users.Controllers.js"
import usecasesBlogControllers from "./Usecases/Blog.Controllers"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers"
import usecasesMeControllers from "./Usecases/Me.Controllers"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers"
import usecasesUsersControllers from "./Usecases/Users.Controllers"

export {
usecasesBlogControllers,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases/Blog.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
import { matchFor } from "api/lib/matchFor.js"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services"
import { Duration, Effect, Schedule } from "effect"
import { NonNegativeInt } from "effect-app/schema"
import { BlogPost } from "models/Blog.js"
import { BlogRsc } from "resources.js"
import { BogusEvent } from "resources/Events.js"
import { BlogPost } from "models/Blog"
import { BlogRsc } from "resources"
import { BogusEvent } from "resources/Events"

const blog = matchFor(BlogRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/HelloWorld.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { generateFromArbitrary } from "@effect-app/infra/test.arbs"
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { Effect, S } from "effect-app"
import { User } from "models/User.js"
import { HelloWorldRsc } from "resources.js"
import { User } from "models/User"
import { HelloWorldRsc } from "resources"

const helloWorld = matchFor(HelloWorldRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Me.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { MeRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { MeRsc } from "resources"

const me = matchFor(MeRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Operations.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { Operations } from "api/services.js"
import { OperationsRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { Operations } from "api/services"
import { OperationsRsc } from "resources"

const operations = matchFor(OperationsRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/Users.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { ReadonlyArray } from "effect"
import { Order } from "effect-app"
import { UsersRsc } from "resources.js"
import type { UserView } from "resources/Views.js"
import { UsersRsc } from "resources"
import type { UserView } from "resources/Views"

const users = matchFor(UsersRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/_global.ext.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
import type {} from "./services/DBContext.js"
import type {} from "./services/Events.js"
import type {} from "./services/UserProfile.js"
import type {} from "./services/DBContext"
import type {} from "./services/Events"
import type {} from "./services/UserProfile"
14 changes: 7 additions & 7 deletions api/src/api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,16 @@ import { Live as OperationsLive } from "@effect-app/infra/services/Operations/li
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMapContainer"
import { NodeContext } from "@effect/platform-node"
import { all } from "api/routes.js"
import { all } from "api/routes"
import { Effect, Layer, Ref } from "effect-app"
import { GenericTag } from "effect/Context"
import { createServer } from "node:http"
import { MergedConfig } from "./config.js"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http.js"
import * as MW from "./middleware/index.js"
import { RequestContextMiddleware } from "./middleware/index.js"
import { BlogPostRepo, UserRepo } from "./services.js"
import { Events } from "./services/Events.js"
import { MergedConfig } from "./config"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http"
import * as MW from "./middleware/index"
import { RequestContextMiddleware } from "./middleware/index"
import { BlogPostRepo, UserRepo } from "./services"
import { Events } from "./services/Events"

export const devApi = MergedConfig
.andThen((cfg) => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/config.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Config, Effect } from "effect-app"
import { secretURL } from "effect-app/Config/SecretURL"
import * as SecretURL from "effect-app/Config/SecretURL"
import { BaseConfig } from "./baseConfig.js"
import { BaseConfig } from "./baseConfig"

const STORAGE_VERSION = "1"

Expand DownExpand Up@@ -49,7 +49,7 @@ export interface ApiConfig extends ConfigA<typeof ApiConfig> {}

export interface ApiMainConfig extends ApiConfig, BaseConfig {}

export * from "./baseConfig.js"
export * from "./baseConfig"

export const MergedConfig = ApiConfig
.andThen((apiConfig) => BaseConfig.andThen((baseConfig) => ({ ...baseConfig, ...apiConfig })))
Expand Down
10 changes: 5 additions & 5 deletions api/src/lib/RequestEnv.ts
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import { Role } from "models/User.js"
import { Role } from "models/User"

import { HttpServerRequest } from "@effect-app/infra/api/http"
import { JWTError, type RequestHandler } from "@effect-app/infra/api/routing"
import type { RequestContext } from "@effect-app/infra/RequestContext"
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import type { StructFields } from "@effect-app/schema"
import { Req as Req_ } from "@effect-app/schema/REST"
import { NotLoggedInError, UnauthorizedError } from "api/errors.js"
import { Auth0Config, checkJWTI } from "api/middleware/auth.js"
import { NotLoggedInError, UnauthorizedError } from "api/errors"
import { Auth0Config, checkJWTI } from "api/middleware/auth"
import { Duration, Effect, Exit, Layer, Option, Request } from "effect-app"
import {
makeUserProfileFromAuthorizationHeader,
makeUserProfileFromUserHeader,
UserProfile
} from "../services/UserProfile.js"
} from "../services/UserProfile"

// Workaround for the error when using
// import type { AllowAnonymous, RequestConfig } from "resources/lib.js"
// import type { AllowAnonymous, RequestConfig } from "resources/lib"

export type RequestConfig = { allowAnonymous?: true; allowedRoles?: readonly Role[] }

Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/matchFor.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,9 @@ import { defaultErrorHandler, match } from "@effect-app/infra/api/routing"
import { Effect, S } from "effect-app"
import type { SupportedErrors } from "effect-app/client/errors"
import { REST } from "effect-app/schema"
import { handleRequestEnv } from "./RequestEnv.js"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv.js"
import type {} from "resources/lib.js"
import { handleRequestEnv } from "./RequestEnv"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv"
import type {} from "resources/lib"

function handle<
TModule extends Record<
Expand Down
8 changes: 4 additions & 4 deletions api/src/main.ts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import "@effect-app/fluent-extensions"
import { runMain } from "./lib/basicRuntime.js"
import { runMain } from "./lib/basicRuntime"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { faker } from "@faker-js/faker"
import { api, devApi } from "api/api.js"
import { api, devApi } from "api/api"
import { Layer } from "effect-app"
import { setFaker } from "effect-app/faker"
import { MergedConfig } from "./config.js"
import { TracingLive } from "./observability.js"
import { MergedConfig } from "./config"
import { TracingLive } from "./observability"

setFaker(faker)

Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/Middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
import type { NotLoggedInError } from "@effect-app/infra/errors"
import type * as App from "@effect/platform/Http/App"
import type { Effect } from "effect-app"
import * as internal from "./internal/middlewares.js"
import * as internal from "./internal/middlewares"

/**
* Add access logs for handled requests. The log runs before each request.
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/RequestContextMiddleware.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { RequestContext } from "@effect-app/infra/RequestContext"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Effect, S } from "effect-app"
import { RequestId } from "effect-app/ids"
import { NonEmptyString255 } from "effect-app/schema"
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/auth.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable unused-imports/no-unused-vars */
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Config, Effect } from "effect-app"
import {
auth,
Expand Down
6 changes: 3 additions & 3 deletions api/src/middleware/events.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { reportError } from "@effect-app/infra/errorReporter"
import { HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Duration, Effect, S, Schedule, Stream } from "effect-app"
import { ClientEvents } from "resources.js"
import { Events } from "../services/Events.js"
import { ClientEvents } from "resources"
import { Events } from "../services/Events"

export const events = Effect
.gen(function*($) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/health.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http"

export function serverHealth(version: string) {
return HttpRouter.get(
Expand Down
12 changes: 6 additions & 6 deletions api/src/middleware/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./*.ts}
export * from "./auth.js"
export * from "./events.js"
export * from "./health.js"
export * from "./Middlewares.js"
export * from "./openapi.js"
export * from "./RequestContextMiddleware.js"
export * from "./auth"
export * from "./events"
export * from "./health"
export * from "./Middlewares"
export * from "./openapi"
export * from "./RequestContextMiddleware"
// codegen:end
4 changes: 2 additions & 2 deletions api/src/middleware/internal/middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@ import { NotLoggedInError } from "@effect-app/infra/errors"
import * as Middleware from "@effect/platform/Http/Middleware"
import * as ServerRequest from "@effect/platform/Http/ServerRequest"
import * as ServerResponse from "@effect/platform/Http/ServerResponse"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Effect } from "effect-app"
import * as Either from "effect/Either"
import * as FiberRef from "effect/FiberRef"
import { pipe } from "effect/Function"
import * as HashMap from "effect/HashMap"
import * as Metric from "effect/Metric"
import type * as Middlewares from "../Middlewares.js"
import type * as Middlewares from "../Middlewares"

export const accessLog = (level: "Info" | "Warning" | "Debug" = "Info") =>
Middleware.make((app) =>
Expand Down
2 changes: 1 addition & 1 deletion api/src/migrate.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMap
import { StoreMakerLayer } from "@effect-app/infra/services/Store/index"
import * as HttpClientNode from "@effect/platform-node/NodeHttpClient"
import { Layer } from "effect-app"
import { SendgridConfig, StorageConfig } from "./config.js"
import { SendgridConfig, StorageConfig } from "./config"

export const RepoLive = StorageConfig
.andThen(StoreMakerLayer)
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { S } from "effect-app"
import { UserFromId } from "./User.js"
import { UserFromId } from "./User"

export const BlogPostId = S.prefixedStringId<BlogPostId>()("post", "BlogPostId")
export interface BlogPostIdBrand {
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/roles.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Poor man's RBAC

import type { Role } from "./User.js"
import type { Role } from "./User"

/**
* Allow role access
Expand Down
2 changes: 1 addition & 1 deletion api/src/observability.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import {
} from "@sentry/opentelemetry"
import { Effect, Layer, Secret } from "effect-app"
import tcpPortUsed from "tcp-port-used"
import { BaseConfig } from "./config.js"
import { BaseConfig } from "./config"

const appConfig = BaseConfig.runSync

Expand Down
14 changes: 7 additions & 7 deletions api/src/resources.ts
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import "./resources/lib/operations.js"
import "./resources/lib/operations"
import type {} from "@effect/platform/Http/Client"

export { ClientEvents } from "./resources/Events.js"
export { ClientEvents } from "./resources/Events"

// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/_global*.ts, ./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/Views.ts, ./resources/errors.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }}
export * as BlogRsc from "./resources/Blog.js"
export * as HelloWorldRsc from "./resources/HelloWorld.js"
export * as MeRsc from "./resources/Me.js"
export * as OperationsRsc from "./resources/Operations.js"
export * as UsersRsc from "./resources/Users.js"
export * as BlogRsc from "./resources/Blog"
export * as HelloWorldRsc from "./resources/HelloWorld"
export * as MeRsc from "./resources/Me"
export * as OperationsRsc from "./resources/Operations"
export * as UsersRsc from "./resources/Users"
// codegen:end
8 changes: 4 additions & 4 deletions api/src/resources/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./Blog/*.ts, export: { as: 'PascalCase' }, nodir: false }
export * as CreatePost from "./Blog/CreatePost.js"
export * as FindPost from "./Blog/FindPost.js"
export * as GetPosts from "./Blog/GetPosts.js"
export * as PublishPost from "./Blog/PublishPost.js"
export * as CreatePost from "./Blog/CreatePost"
export * as FindPost from "./Blog/FindPost"
export * as GetPosts from "./Blog/GetPosts"
export * as PublishPost from "./Blog/PublishPost"
// codegen:end
// codegen:start {preset: meta, sourcePrefix: src/resources/}
export const meta = { moduleName: "Blog" }
Expand Down
4 changes: 2 additions & 2 deletions api/src/resources/Blog/CreatePost.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { BlogPost, BlogPostId } from "models/Blog.js"
import { S } from "resources/lib.js"
import { BlogPost, BlogPostId } from "models/Blog"
import { S } from "resources/lib"

export class CreatePostRequest extends S.Req({ allowAnonymous: true, allowRoles: ["user"] })<CreatePostRequest>()(
BlogPost.pick("title", "body")
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
FROM node:20-alpine
FROM oven/bun:1

RUN npm i -g pnpm

# Install CUPS/AVAHI
RUN apk update --no-cache && apk add --no-cache cups cups-filters avahi inotify-tools
RUN bun install -g pnpm

WORKDIR /app

Expand All@@ -12,15 +9,15 @@ ENV NODE_ENV production
# pnpm fetch does require only lockfile
COPY patches ./patches
COPY pnpm-lock.yaml .npmrc ./
RUN pnpm fetch --prod
RUN bunx pnpm fetch --prod

COPY package.json pnpm-workspace.yaml ./

COPY api/package.json ./api/

# As we're going to deploy, we want only the minimal production dependencies.
# TODO
RUN pnpm install --frozen-lockfile --prod
RUN bunx pnpm install --frozen-lockfile --prod
#RUN --mount=type=cache,target=/root/.pnpm pnpm_CACHE_FOLDER=/root/.pnpm pnpm install --frozen-lockfile --prod

COPY api/dist ./api/dist
Expand All@@ -35,4 +32,4 @@ ARG API_VERSION
ENV API_VERSION=${API_VERSION:-docker_default}
ENV SENTRY_RELEASE=${API_VERSION:-docker_default}

CMD ["pnpm", "start"]
CMD ["bunx", "pnpm", "start"]
7 changes: 4 additions & 3 deletions api/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,12 @@
"test:run": "pnpm run test run --passWithNoTests",
"testsuite": "pnpm circular && pnpm run test:run && pnpm lint",
"dev": "NODE_ENV=development nodemon --signal SIGTERM --exec pnpm dev:vite",
"dev:compiled": "node -r source-map-support/register --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:vite | ../scripts/humanlog.sh",
"start": "pnpm start:compiled",
"dev:compiled": "bun --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:bun | ../scripts/humanlog.sh",
"start": "pnpm start:bun",
"start:compiled": "node -r source-map-support/register ./dist/main.js",
"start:vite": "vite-node ./src/main.ts",
"start:bun": "bun ./src/main.ts",
"ncu": "ncu",
"extract:i18n": "formatjs extract './**/*.ts' --ignore './**/*.d.ts' --format src/i18n/extraction-formatter.cjs --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/i18n/extracted/en.json"
},
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// codegen:start {preset: barrel, include: ./Usecases/*.ts, import: default}
import usecasesBlogControllers from "./Usecases/Blog.Controllers.js"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers.js"
import usecasesMeControllers from "./Usecases/Me.Controllers.js"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers.js"
import usecasesUsersControllers from "./Usecases/Users.Controllers.js"
import usecasesBlogControllers from "./Usecases/Blog.Controllers"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers"
import usecasesMeControllers from "./Usecases/Me.Controllers"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers"
import usecasesUsersControllers from "./Usecases/Users.Controllers"

export {
usecasesBlogControllers,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases/Blog.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
import { matchFor } from "api/lib/matchFor.js"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services"
import { Duration, Effect, Schedule } from "effect"
import { NonNegativeInt } from "effect-app/schema"
import { BlogPost } from "models/Blog.js"
import { BlogRsc } from "resources.js"
import { BogusEvent } from "resources/Events.js"
import { BlogPost } from "models/Blog"
import { BlogRsc } from "resources"
import { BogusEvent } from "resources/Events"

const blog = matchFor(BlogRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/HelloWorld.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { generateFromArbitrary } from "@effect-app/infra/test.arbs"
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { Effect, S } from "effect-app"
import { User } from "models/User.js"
import { HelloWorldRsc } from "resources.js"
import { User } from "models/User"
import { HelloWorldRsc } from "resources"

const helloWorld = matchFor(HelloWorldRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Me.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { MeRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { MeRsc } from "resources"

const me = matchFor(MeRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Operations.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { Operations } from "api/services.js"
import { OperationsRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { Operations } from "api/services"
import { OperationsRsc } from "resources"

const operations = matchFor(OperationsRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/Users.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { ReadonlyArray } from "effect"
import { Order } from "effect-app"
import { UsersRsc } from "resources.js"
import type { UserView } from "resources/Views.js"
import { UsersRsc } from "resources"
import type { UserView } from "resources/Views"

const users = matchFor(UsersRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/_global.ext.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
import type {} from "./services/DBContext.js"
import type {} from "./services/Events.js"
import type {} from "./services/UserProfile.js"
import type {} from "./services/DBContext"
import type {} from "./services/Events"
import type {} from "./services/UserProfile"
14 changes: 7 additions & 7 deletions api/src/api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,16 @@ import { Live as OperationsLive } from "@effect-app/infra/services/Operations/li
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMapContainer"
import { NodeContext } from "@effect/platform-node"
import { all } from "api/routes.js"
import { all } from "api/routes"
import { Effect, Layer, Ref } from "effect-app"
import { GenericTag } from "effect/Context"
import { createServer } from "node:http"
import { MergedConfig } from "./config.js"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http.js"
import * as MW from "./middleware/index.js"
import { RequestContextMiddleware } from "./middleware/index.js"
import { BlogPostRepo, UserRepo } from "./services.js"
import { Events } from "./services/Events.js"
import { MergedConfig } from "./config"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http"
import * as MW from "./middleware/index"
import { RequestContextMiddleware } from "./middleware/index"
import { BlogPostRepo, UserRepo } from "./services"
import { Events } from "./services/Events"

export const devApi = MergedConfig
.andThen((cfg) => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/config.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Config, Effect } from "effect-app"
import { secretURL } from "effect-app/Config/SecretURL"
import * as SecretURL from "effect-app/Config/SecretURL"
import { BaseConfig } from "./baseConfig.js"
import { BaseConfig } from "./baseConfig"

const STORAGE_VERSION = "1"

Expand DownExpand Up@@ -49,7 +49,7 @@ export interface ApiConfig extends ConfigA<typeof ApiConfig> {}

export interface ApiMainConfig extends ApiConfig, BaseConfig {}

export * from "./baseConfig.js"
export * from "./baseConfig"

export const MergedConfig = ApiConfig
.andThen((apiConfig) => BaseConfig.andThen((baseConfig) => ({ ...baseConfig, ...apiConfig })))
Expand Down
10 changes: 5 additions & 5 deletions api/src/lib/RequestEnv.ts
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import { Role } from "models/User.js"
import { Role } from "models/User"

import { HttpServerRequest } from "@effect-app/infra/api/http"
import { JWTError, type RequestHandler } from "@effect-app/infra/api/routing"
import type { RequestContext } from "@effect-app/infra/RequestContext"
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import type { StructFields } from "@effect-app/schema"
import { Req as Req_ } from "@effect-app/schema/REST"
import { NotLoggedInError, UnauthorizedError } from "api/errors.js"
import { Auth0Config, checkJWTI } from "api/middleware/auth.js"
import { NotLoggedInError, UnauthorizedError } from "api/errors"
import { Auth0Config, checkJWTI } from "api/middleware/auth"
import { Duration, Effect, Exit, Layer, Option, Request } from "effect-app"
import {
makeUserProfileFromAuthorizationHeader,
makeUserProfileFromUserHeader,
UserProfile
} from "../services/UserProfile.js"
} from "../services/UserProfile"

// Workaround for the error when using
// import type { AllowAnonymous, RequestConfig } from "resources/lib.js"
// import type { AllowAnonymous, RequestConfig } from "resources/lib"

export type RequestConfig = { allowAnonymous?: true; allowedRoles?: readonly Role[] }

Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/matchFor.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,9 @@ import { defaultErrorHandler, match } from "@effect-app/infra/api/routing"
import { Effect, S } from "effect-app"
import type { SupportedErrors } from "effect-app/client/errors"
import { REST } from "effect-app/schema"
import { handleRequestEnv } from "./RequestEnv.js"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv.js"
import type {} from "resources/lib.js"
import { handleRequestEnv } from "./RequestEnv"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv"
import type {} from "resources/lib"

function handle<
TModule extends Record<
Expand Down
8 changes: 4 additions & 4 deletions api/src/main.ts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import "@effect-app/fluent-extensions"
import { runMain } from "./lib/basicRuntime.js"
import { runMain } from "./lib/basicRuntime"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { faker } from "@faker-js/faker"
import { api, devApi } from "api/api.js"
import { api, devApi } from "api/api"
import { Layer } from "effect-app"
import { setFaker } from "effect-app/faker"
import { MergedConfig } from "./config.js"
import { TracingLive } from "./observability.js"
import { MergedConfig } from "./config"
import { TracingLive } from "./observability"

setFaker(faker)

Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/Middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
import type { NotLoggedInError } from "@effect-app/infra/errors"
import type * as App from "@effect/platform/Http/App"
import type { Effect } from "effect-app"
import * as internal from "./internal/middlewares.js"
import * as internal from "./internal/middlewares"

/**
* Add access logs for handled requests. The log runs before each request.
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/RequestContextMiddleware.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { RequestContext } from "@effect-app/infra/RequestContext"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Effect, S } from "effect-app"
import { RequestId } from "effect-app/ids"
import { NonEmptyString255 } from "effect-app/schema"
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/auth.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable unused-imports/no-unused-vars */
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Config, Effect } from "effect-app"
import {
auth,
Expand Down
6 changes: 3 additions & 3 deletions api/src/middleware/events.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { reportError } from "@effect-app/infra/errorReporter"
import { HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Duration, Effect, S, Schedule, Stream } from "effect-app"
import { ClientEvents } from "resources.js"
import { Events } from "../services/Events.js"
import { ClientEvents } from "resources"
import { Events } from "../services/Events"

export const events = Effect
.gen(function*($) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/health.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http"

export function serverHealth(version: string) {
return HttpRouter.get(
Expand Down
12 changes: 6 additions & 6 deletions api/src/middleware/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./*.ts}
export * from "./auth.js"
export * from "./events.js"
export * from "./health.js"
export * from "./Middlewares.js"
export * from "./openapi.js"
export * from "./RequestContextMiddleware.js"
export * from "./auth"
export * from "./events"
export * from "./health"
export * from "./Middlewares"
export * from "./openapi"
export * from "./RequestContextMiddleware"
// codegen:end
4 changes: 2 additions & 2 deletions api/src/middleware/internal/middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@ import { NotLoggedInError } from "@effect-app/infra/errors"
import * as Middleware from "@effect/platform/Http/Middleware"
import * as ServerRequest from "@effect/platform/Http/ServerRequest"
import * as ServerResponse from "@effect/platform/Http/ServerResponse"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Effect } from "effect-app"
import * as Either from "effect/Either"
import * as FiberRef from "effect/FiberRef"
import { pipe } from "effect/Function"
import * as HashMap from "effect/HashMap"
import * as Metric from "effect/Metric"
import type * as Middlewares from "../Middlewares.js"
import type * as Middlewares from "../Middlewares"

export const accessLog = (level: "Info" | "Warning" | "Debug" = "Info") =>
Middleware.make((app) =>
Expand Down
2 changes: 1 addition & 1 deletion api/src/migrate.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMap
import { StoreMakerLayer } from "@effect-app/infra/services/Store/index"
import * as HttpClientNode from "@effect/platform-node/NodeHttpClient"
import { Layer } from "effect-app"
import { SendgridConfig, StorageConfig } from "./config.js"
import { SendgridConfig, StorageConfig } from "./config"

export const RepoLive = StorageConfig
.andThen(StoreMakerLayer)
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { S } from "effect-app"
import { UserFromId } from "./User.js"
import { UserFromId } from "./User"

export const BlogPostId = S.prefixedStringId<BlogPostId>()("post", "BlogPostId")
export interface BlogPostIdBrand {
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/roles.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Poor man's RBAC

import type { Role } from "./User.js"
import type { Role } from "./User"

/**
* Allow role access
Expand Down
2 changes: 1 addition & 1 deletion api/src/observability.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import {
} from "@sentry/opentelemetry"
import { Effect, Layer, Secret } from "effect-app"
import tcpPortUsed from "tcp-port-used"
import { BaseConfig } from "./config.js"
import { BaseConfig } from "./config"

const appConfig = BaseConfig.runSync

Expand Down
14 changes: 7 additions & 7 deletions api/src/resources.ts
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import "./resources/lib/operations.js"
import "./resources/lib/operations"
import type {} from "@effect/platform/Http/Client"

export { ClientEvents } from "./resources/Events.js"
export { ClientEvents } from "./resources/Events"

// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/_global*.ts, ./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/Views.ts, ./resources/errors.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }}
export * as BlogRsc from "./resources/Blog.js"
export * as HelloWorldRsc from "./resources/HelloWorld.js"
export * as MeRsc from "./resources/Me.js"
export * as OperationsRsc from "./resources/Operations.js"
export * as UsersRsc from "./resources/Users.js"
export * as BlogRsc from "./resources/Blog"
export * as HelloWorldRsc from "./resources/HelloWorld"
export * as MeRsc from "./resources/Me"
export * as OperationsRsc from "./resources/Operations"
export * as UsersRsc from "./resources/Users"
// codegen:end
8 changes: 4 additions & 4 deletions api/src/resources/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./Blog/*.ts, export: { as: 'PascalCase' }, nodir: false }
export * as CreatePost from "./Blog/CreatePost.js"
export * as FindPost from "./Blog/FindPost.js"
export * as GetPosts from "./Blog/GetPosts.js"
export * as PublishPost from "./Blog/PublishPost.js"
export * as CreatePost from "./Blog/CreatePost"
export * as FindPost from "./Blog/FindPost"
export * as GetPosts from "./Blog/GetPosts"
export * as PublishPost from "./Blog/PublishPost"
// codegen:end
// codegen:start {preset: meta, sourcePrefix: src/resources/}
export const meta = { moduleName: "Blog" }
Expand Down
4 changes: 2 additions & 2 deletions api/src/resources/Blog/CreatePost.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { BlogPost, BlogPostId } from "models/Blog.js"
import { S } from "resources/lib.js"
import { BlogPost, BlogPostId } from "models/Blog"
import { S } from "resources/lib"

export class CreatePostRequest extends S.Req({ allowAnonymous: true, allowRoles: ["user"] })<CreatePostRequest>()(
BlogPost.pick("title", "body")
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
FROM node:20-alpine
FROM oven/bun:1

RUN npm i -g pnpm

# Install CUPS/AVAHI
RUN apk update --no-cache && apk add --no-cache cups cups-filters avahi inotify-tools
RUN bun install -g pnpm

WORKDIR /app

Expand All@@ -12,15 +9,15 @@ ENV NODE_ENV production
# pnpm fetch does require only lockfile
COPY patches ./patches
COPY pnpm-lock.yaml .npmrc ./
RUN pnpm fetch --prod
RUN bunx pnpm fetch --prod

COPY package.json pnpm-workspace.yaml ./

COPY api/package.json ./api/

# As we're going to deploy, we want only the minimal production dependencies.
# TODO
RUN pnpm install --frozen-lockfile --prod
RUN bunx pnpm install --frozen-lockfile --prod
#RUN --mount=type=cache,target=/root/.pnpm pnpm_CACHE_FOLDER=/root/.pnpm pnpm install --frozen-lockfile --prod

COPY api/dist ./api/dist
Expand All@@ -35,4 +32,4 @@ ARG API_VERSION
ENV API_VERSION=${API_VERSION:-docker_default}
ENV SENTRY_RELEASE=${API_VERSION:-docker_default}

CMD ["pnpm", "start"]
CMD ["bunx", "pnpm", "start"]
7 changes: 4 additions & 3 deletions api/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,12 @@
"test:run": "pnpm run test run --passWithNoTests",
"testsuite": "pnpm circular && pnpm run test:run && pnpm lint",
"dev": "NODE_ENV=development nodemon --signal SIGTERM --exec pnpm dev:vite",
"dev:compiled": "node -r source-map-support/register --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:vite | ../scripts/humanlog.sh",
"start": "pnpm start:compiled",
"dev:compiled": "bun --inspect ./dist/main.js | ../scripts/humanlog.sh",
"dev:vite": "pnpm start:bun | ../scripts/humanlog.sh",
"start": "pnpm start:bun",
"start:compiled": "node -r source-map-support/register ./dist/main.js",
"start:vite": "vite-node ./src/main.ts",
"start:bun": "bun ./src/main.ts",
"ncu": "ncu",
"extract:i18n": "formatjs extract './**/*.ts' --ignore './**/*.d.ts' --format src/i18n/extraction-formatter.cjs --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/i18n/extracted/en.json"
},
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// codegen:start {preset: barrel, include: ./Usecases/*.ts, import: default}
import usecasesBlogControllers from "./Usecases/Blog.Controllers.js"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers.js"
import usecasesMeControllers from "./Usecases/Me.Controllers.js"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers.js"
import usecasesUsersControllers from "./Usecases/Users.Controllers.js"
import usecasesBlogControllers from "./Usecases/Blog.Controllers"
import usecasesHelloWorldControllers from "./Usecases/HelloWorld.Controllers"
import usecasesMeControllers from "./Usecases/Me.Controllers"
import usecasesOperationsControllers from "./Usecases/Operations.Controllers"
import usecasesUsersControllers from "./Usecases/Users.Controllers"

export {
usecasesBlogControllers,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Usecases/Blog.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
import { matchFor } from "api/lib/matchFor.js"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { BlogPostRepo, Events, forkOperationWithEffect, Operations, UserRepo } from "api/services"
import { Duration, Effect, Schedule } from "effect"
import { NonNegativeInt } from "effect-app/schema"
import { BlogPost } from "models/Blog.js"
import { BlogRsc } from "resources.js"
import { BogusEvent } from "resources/Events.js"
import { BlogPost } from "models/Blog"
import { BlogRsc } from "resources"
import { BogusEvent } from "resources/Events"

const blog = matchFor(BlogRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/HelloWorld.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { generateFromArbitrary } from "@effect-app/infra/test.arbs"
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { Effect, S } from "effect-app"
import { User } from "models/User.js"
import { HelloWorldRsc } from "resources.js"
import { User } from "models/User"
import { HelloWorldRsc } from "resources"

const helloWorld = matchFor(HelloWorldRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Me.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { MeRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { MeRsc } from "resources"

const me = matchFor(MeRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/Usecases/Operations.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { matchFor } from "api/lib/matchFor.js"
import { Operations } from "api/services.js"
import { OperationsRsc } from "resources.js"
import { matchFor } from "api/lib/matchFor"
import { Operations } from "api/services"
import { OperationsRsc } from "resources"

const operations = matchFor(OperationsRsc)

Expand Down
8 changes: 4 additions & 4 deletions api/src/Usecases/Users.Controllers.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { matchFor } from "api/lib/matchFor.js"
import { UserRepo } from "api/services.js"
import { matchFor } from "api/lib/matchFor"
import { UserRepo } from "api/services"
import { ReadonlyArray } from "effect"
import { Order } from "effect-app"
import { UsersRsc } from "resources.js"
import type { UserView } from "resources/Views.js"
import { UsersRsc } from "resources"
import type { UserView } from "resources/Views"

const users = matchFor(UsersRsc)

Expand Down
6 changes: 3 additions & 3 deletions api/src/_global.ext.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
import type {} from "./services/DBContext.js"
import type {} from "./services/Events.js"
import type {} from "./services/UserProfile.js"
import type {} from "./services/DBContext"
import type {} from "./services/Events"
import type {} from "./services/UserProfile"
14 changes: 7 additions & 7 deletions api/src/api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,16 @@ import { Live as OperationsLive } from "@effect-app/infra/services/Operations/li
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMapContainer"
import { NodeContext } from "@effect/platform-node"
import { all } from "api/routes.js"
import { all } from "api/routes"
import { Effect, Layer, Ref } from "effect-app"
import { GenericTag } from "effect/Context"
import { createServer } from "node:http"
import { MergedConfig } from "./config.js"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http.js"
import * as MW from "./middleware/index.js"
import { RequestContextMiddleware } from "./middleware/index.js"
import { BlogPostRepo, UserRepo } from "./services.js"
import { Events } from "./services/Events.js"
import { MergedConfig } from "./config"
import { HttpClientNode, HttpMiddleware, HttpNode, HttpRouter, HttpServer } from "./lib/http"
import * as MW from "./middleware/index"
import { RequestContextMiddleware } from "./middleware/index"
import { BlogPostRepo, UserRepo } from "./services"
import { Events } from "./services/Events"

export const devApi = MergedConfig
.andThen((cfg) => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/config.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Config, Effect } from "effect-app"
import { secretURL } from "effect-app/Config/SecretURL"
import * as SecretURL from "effect-app/Config/SecretURL"
import { BaseConfig } from "./baseConfig.js"
import { BaseConfig } from "./baseConfig"

const STORAGE_VERSION = "1"

Expand DownExpand Up@@ -49,7 +49,7 @@ export interface ApiConfig extends ConfigA<typeof ApiConfig> {}

export interface ApiMainConfig extends ApiConfig, BaseConfig {}

export * from "./baseConfig.js"
export * from "./baseConfig"

export const MergedConfig = ApiConfig
.andThen((apiConfig) => BaseConfig.andThen((baseConfig) => ({ ...baseConfig, ...apiConfig })))
Expand Down
10 changes: 5 additions & 5 deletions api/src/lib/RequestEnv.ts
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import { Role } from "models/User.js"
import { Role } from "models/User"

import { HttpServerRequest } from "@effect-app/infra/api/http"
import { JWTError, type RequestHandler } from "@effect-app/infra/api/routing"
import type { RequestContext } from "@effect-app/infra/RequestContext"
import { RequestContextContainer } from "@effect-app/infra/services/RequestContextContainer"
import type { StructFields } from "@effect-app/schema"
import { Req as Req_ } from "@effect-app/schema/REST"
import { NotLoggedInError, UnauthorizedError } from "api/errors.js"
import { Auth0Config, checkJWTI } from "api/middleware/auth.js"
import { NotLoggedInError, UnauthorizedError } from "api/errors"
import { Auth0Config, checkJWTI } from "api/middleware/auth"
import { Duration, Effect, Exit, Layer, Option, Request } from "effect-app"
import {
makeUserProfileFromAuthorizationHeader,
makeUserProfileFromUserHeader,
UserProfile
} from "../services/UserProfile.js"
} from "../services/UserProfile"

// Workaround for the error when using
// import type { AllowAnonymous, RequestConfig } from "resources/lib.js"
// import type { AllowAnonymous, RequestConfig } from "resources/lib"

export type RequestConfig = { allowAnonymous?: true; allowedRoles?: readonly Role[] }

Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/matchFor.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,9 @@ import { defaultErrorHandler, match } from "@effect-app/infra/api/routing"
import { Effect, S } from "effect-app"
import type { SupportedErrors } from "effect-app/client/errors"
import { REST } from "effect-app/schema"
import { handleRequestEnv } from "./RequestEnv.js"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv.js"
import type {} from "resources/lib.js"
import { handleRequestEnv } from "./RequestEnv"
import type { CTX, GetContext, GetCTX, RequestEnv } from "./RequestEnv"
import type {} from "resources/lib"

function handle<
TModule extends Record<
Expand Down
8 changes: 4 additions & 4 deletions api/src/main.ts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import "@effect-app/fluent-extensions"
import { runMain } from "./lib/basicRuntime.js"
import { runMain } from "./lib/basicRuntime"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { faker } from "@faker-js/faker"
import { api, devApi } from "api/api.js"
import { api, devApi } from "api/api"
import { Layer } from "effect-app"
import { setFaker } from "effect-app/faker"
import { MergedConfig } from "./config.js"
import { TracingLive } from "./observability.js"
import { MergedConfig } from "./config"
import { TracingLive } from "./observability"

setFaker(faker)

Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/Middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
import type { NotLoggedInError } from "@effect-app/infra/errors"
import type * as App from "@effect/platform/Http/App"
import type { Effect } from "effect-app"
import * as internal from "./internal/middlewares.js"
import * as internal from "./internal/middlewares"

/**
* Add access logs for handled requests. The log runs before each request.
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/RequestContextMiddleware.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { RequestContext } from "@effect-app/infra/RequestContext"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Effect, S } from "effect-app"
import { RequestId } from "effect-app/ids"
import { NonEmptyString255 } from "effect-app/schema"
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/auth.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable unused-imports/no-unused-vars */
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpMiddleware, HttpServerRequest, HttpServerResponse } from "api/lib/http"
import { Config, Effect } from "effect-app"
import {
auth,
Expand Down
6 changes: 3 additions & 3 deletions api/src/middleware/events.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
import { setupRequestContext } from "@effect-app/infra/api/setupRequest"
import { reportError } from "@effect-app/infra/errorReporter"
import { HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Duration, Effect, S, Schedule, Stream } from "effect-app"
import { ClientEvents } from "resources.js"
import { Events } from "../services/Events.js"
import { ClientEvents } from "resources"
import { Events } from "../services/Events"

export const events = Effect
.gen(function*($) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/middleware/health.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http.js"
import { HttpMiddleware, HttpRouter, HttpServerResponse } from "api/lib/http"

export function serverHealth(version: string) {
return HttpRouter.get(
Expand Down
12 changes: 6 additions & 6 deletions api/src/middleware/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./*.ts}
export * from "./auth.js"
export * from "./events.js"
export * from "./health.js"
export * from "./Middlewares.js"
export * from "./openapi.js"
export * from "./RequestContextMiddleware.js"
export * from "./auth"
export * from "./events"
export * from "./health"
export * from "./Middlewares"
export * from "./openapi"
export * from "./RequestContextMiddleware"
// codegen:end
4 changes: 2 additions & 2 deletions api/src/middleware/internal/middlewares.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@ import { NotLoggedInError } from "@effect-app/infra/errors"
import * as Middleware from "@effect/platform/Http/Middleware"
import * as ServerRequest from "@effect/platform/Http/ServerRequest"
import * as ServerResponse from "@effect/platform/Http/ServerResponse"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http.js"
import { HttpBody, HttpHeaders, HttpServerResponse } from "api/lib/http"
import { Effect } from "effect-app"
import * as Either from "effect/Either"
import * as FiberRef from "effect/FiberRef"
import { pipe } from "effect/Function"
import * as HashMap from "effect/HashMap"
import * as Metric from "effect/Metric"
import type * as Middlewares from "../Middlewares.js"
import type * as Middlewares from "../Middlewares"

export const accessLog = (level: "Info" | "Warning" | "Debug" = "Info") =>
Middleware.make((app) =>
Expand Down
2 changes: 1 addition & 1 deletion api/src/migrate.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { ContextMapContainer } from "@effect-app/infra/services/Store/ContextMap
import { StoreMakerLayer } from "@effect-app/infra/services/Store/index"
import * as HttpClientNode from "@effect/platform-node/NodeHttpClient"
import { Layer } from "effect-app"
import { SendgridConfig, StorageConfig } from "./config.js"
import { SendgridConfig, StorageConfig } from "./config"

export const RepoLive = StorageConfig
.andThen(StoreMakerLayer)
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { S } from "effect-app"
import { UserFromId } from "./User.js"
import { UserFromId } from "./User"

export const BlogPostId = S.prefixedStringId<BlogPostId>()("post", "BlogPostId")
export interface BlogPostIdBrand {
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/roles.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Poor man's RBAC

import type { Role } from "./User.js"
import type { Role } from "./User"

/**
* Allow role access
Expand Down
2 changes: 1 addition & 1 deletion api/src/observability.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import {
} from "@sentry/opentelemetry"
import { Effect, Layer, Secret } from "effect-app"
import tcpPortUsed from "tcp-port-used"
import { BaseConfig } from "./config.js"
import { BaseConfig } from "./config"

const appConfig = BaseConfig.runSync

Expand Down
14 changes: 7 additions & 7 deletions api/src/resources.ts
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import "./resources/lib/operations.js"
import "./resources/lib/operations"
import type {} from "@effect/platform/Http/Client"

export { ClientEvents } from "./resources/Events.js"
export { ClientEvents } from "./resources/Events"

// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/_global*.ts, ./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/Views.ts, ./resources/errors.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }}
export * as BlogRsc from "./resources/Blog.js"
export * as HelloWorldRsc from "./resources/HelloWorld.js"
export * as MeRsc from "./resources/Me.js"
export * as OperationsRsc from "./resources/Operations.js"
export * as UsersRsc from "./resources/Users.js"
export * as BlogRsc from "./resources/Blog"
export * as HelloWorldRsc from "./resources/HelloWorld"
export * as MeRsc from "./resources/Me"
export * as OperationsRsc from "./resources/Operations"
export * as UsersRsc from "./resources/Users"
// codegen:end
8 changes: 4 additions & 4 deletions api/src/resources/Blog.ts
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
// codegen:start {preset: barrel, include: ./Blog/*.ts, export: { as: 'PascalCase' }, nodir: false }
export * as CreatePost from "./Blog/CreatePost.js"
export * as FindPost from "./Blog/FindPost.js"
export * as GetPosts from "./Blog/GetPosts.js"
export * as PublishPost from "./Blog/PublishPost.js"
export * as CreatePost from "./Blog/CreatePost"
export * as FindPost from "./Blog/FindPost"
export * as GetPosts from "./Blog/GetPosts"
export * as PublishPost from "./Blog/PublishPost"
// codegen:end
// codegen:start {preset: meta, sourcePrefix: src/resources/}
export const meta = { moduleName: "Blog" }
Expand Down
4 changes: 2 additions & 2 deletions api/src/resources/Blog/CreatePost.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { BlogPost, BlogPostId } from "models/Blog.js"
import { S } from "resources/lib.js"
import { BlogPost, BlogPostId } from "models/Blog"
import { S } from "resources/lib"

export class CreatePostRequest extends S.Req({ allowAnonymous: true, allowRoles: ["user"] })<CreatePostRequest>()(
BlogPost.pick("title", "body")
Expand Down
Loading