Skip to content

Commit

Permalink
fix: fix paths and dev enviornment
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRFranklin committed Mar 30, 2024
1 parent 2b0e4d6 commit c1905d7
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 26 deletions.
1 change: 1 addition & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- TZ=Europe\London
- DB_URL=mongodb://mongo:27017/petio
- SSH_AUTH_SOCK=/ssh-agent
- NODE_ENV=development
entrypoint: ['zsh', '-c', 'while sleep 1000; do :; done']

mongo:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"author": "Petio Team",
"license": "MIT",
"bin": "./pkg/api/dist/index.js",
"bin": "./dist/api/index.js",
"workspaces": [
"pkg/api",
"pkg/frontend",
Expand Down Expand Up @@ -38,7 +38,7 @@
"node16-windows-x64",
"node16-windows-arm64"
],
"outputPath": "dist"
"outputPath": "dist/releases"
},
"packageManager": "[email protected]"
}
16 changes: 0 additions & 16 deletions pkg/api/audit.json

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"watch": "nodemon",
"inspect": "nodemon --exec \"node --require tsconfig-paths/register --require ts-node/register --inspect ./src/app.ts\"",
"build": "tsc && tsc-alias",
"build:prod": "yarn ncc -t build ./src/app.ts -o dist -m",
"build:prod": "yarn ncc -t build ./src/app.ts -o ../../dist/api -m",
"test": "ts-mocha --paths src/**/*.test.ts",
"depcheck": "depcheck",
"lint": "eslint . --ext .ts",
Expand Down
1 change: 0 additions & 1 deletion pkg/api/src/api/routes/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function serveReact(app: Koa, dir: string, urlPath: string) {
app.use(mount(urlPath, spa));
}


export default async (app: Koa) => {
let frontendPath = viewsConfig.frontend;
if (!(await pathExists(path.join(frontendPath, 'index.html')))) {
Expand Down
10 changes: 6 additions & 4 deletions pkg/api/src/config/env/paths.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import path from "path";

// ! This is a workaround for the fact that the process.cwd() is not the same as the root directory of the project
// ! because pkg from vercel adds an additional pkg field that points to the root directory of the project
const proc: Process = process;

type PathsConfig = {
rootDir: string;
appDir: string;
dataDir: string;
viewsDir: string;
};

const proc: Process = process;

const ROOT_DIR = proc.cwd();
const APP_DIR = proc.env.APP_DIR ?? path.join(__dirname, '../../..');
const ROOT_DIR = proc.pkg ? proc.cwd() : path.join(__dirname, '../../../../..');
const APP_DIR = proc.pkg ? path.join(__dirname, "../..") : (proc.env.APP_DIR ?? path.join(__dirname, '../../../../..'));
const VIEWS_DIR = process.env.VIEWS_FOLDER ?? path.join(APP_DIR, './pkg');
const DATA_DIR = process.env.DATA_FOLDER ?? path.join(ROOT_DIR, './data');

Expand Down
2 changes: 0 additions & 2 deletions pkg/api/src/config/env/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import pathConfig from "./paths";

type ViewsConfig = {
frontend: string;
admin: string;
};

const viewsConfig: ViewsConfig = {
frontend: path.join(pathConfig.viewsDir, "./frontend"),
admin: path.join(pathConfig.viewsDir, "./admin"),
};

export default viewsConfig;

0 comments on commit c1905d7

Please sign in to comment.