diff --git a/.gitignore b/.gitignore index 713d500..deed335 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ +dist/ .env diff --git a/README.md b/README.md index b6db64d..1853c17 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,32 @@ mipilin **mipilin** ![website screenshot](./screenshot.png) + +## Running locally + +```sh +## get repository +git clone https://git.sr.ht/~roxwize/mipilin +cd mipilin + +## setup environment variables +cp .env.example .env +$EDITOR .env # If $EDITOR is not set, replace it with your text editor of choice + +## start server +pnpm install +pnpm build # Compile TypeScript files to JavaScript in ./dist/ +pnpm start +``` + +You can also run the server's TypeScript directly by using `pnpm dev`. + +### Environment variables + +Keep your `.env` file to yourself. The only non-sensitive field is `LISTEN_ON_SOCKET`. + +| Variable | Description | Required | +| -------- | ----------- | -------- | +| `LISTEN_ON_SOCKET` | If set to `true` the server will run on a Unix socket at `/run/user/[UUID]/mipilin/mipilin.sock` | no | +| `DATABASE_URL` | URL where your PostgresQL database will be accessed | **yes** | +| `COOKIE_SECRET` | Can be any string, used to sign cookies | **yes** | diff --git a/main.ts b/main.ts index 788020a..fbd8345 100644 --- a/main.ts +++ b/main.ts @@ -137,7 +137,7 @@ object-src 'none'; base-uri 'none';" const path = process.env.LISTEN_ON_SOCKET === "true" ? `/run/user/${process.getuid()}/mipilin/mipilin.sock` : 1337; app.listen(path, () => { - console.log(`mipilin is now listening on ${path}!! Requests will be printed below. Good Luck`); + console.log(`mipilin is now listening on ${typeof path === "number" ? "https://127.0.0.1:" + path + "/" : path}!! Requests will be printed below. Good Luck`); }); })(); diff --git a/package.json b/package.json index 61782c1..c5e8abd 100644 --- a/package.json +++ b/package.json @@ -1,39 +1,41 @@ { - "name": "frontend", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "main.ts", - "scripts": { - "start": "tsx main.ts" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "bcrypt": "^5.1.1", - "body-parser": "^1.20.3", - "connect-flash": "^0.1.1", - "connect-pg-simple": "^10.0.0", - "dayjs": "^1.11.13", - "dotenv": "^16.4.5", - "drizzle-orm": "^0.36.1", - "express": "^4.21.1", - "express-session": "^1.18.1", - "pg": "^8.13.1", - "pug": "^3.0.3", - "typescript": "^5.6.3" - }, - "devDependencies": { - "@types/bcrypt": "^5.0.2", - "@types/body-parser": "^1.19.5", - "@types/connect-flash": "^0.0.40", - "@types/connect-pg-simple": "^7.0.3", - "@types/express": "^5.0.0", - "@types/express-session": "^1.18.0", - "@types/pg": "^8.11.10", - "@types/pug": "^2.0.10", - "drizzle-kit": "^0.28.0", - "tsx": "4.19.2" - } + "name": "frontend", + "version": "1.0.0", + "description": "", + "type": "module", + "main": "main.ts", + "scripts": { + "build": "tsc", + "start": "node dist/main.js", + "dev": "tsx main.ts" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "bcrypt": "^5.1.1", + "body-parser": "^1.20.3", + "connect-flash": "^0.1.1", + "connect-pg-simple": "^10.0.0", + "dayjs": "^1.11.13", + "dotenv": "^16.4.5", + "drizzle-orm": "^0.36.1", + "express": "^4.21.1", + "express-session": "^1.18.1", + "pg": "^8.13.1", + "pug": "^3.0.3", + "typescript": "^5.6.3" + }, + "devDependencies": { + "@types/bcrypt": "^5.0.2", + "@types/body-parser": "^1.19.5", + "@types/connect-flash": "^0.0.40", + "@types/connect-pg-simple": "^7.0.3", + "@types/express": "^5.0.0", + "@types/express-session": "^1.18.0", + "@types/pg": "^8.11.10", + "@types/pug": "^2.0.10", + "drizzle-kit": "^0.28.0", + "tsx": "4.19.2" + } } diff --git a/tsconfig.json b/tsconfig.json index efe9bfb..59ec0e2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,11 @@ { - "compilerOptions": { - "lib": ["ESNext"], - "target": "ES6", - "esModuleInterop": true, - "moduleResolution": "NodeNext", - "module": "NodeNext" - } + "compilerOptions": { + "lib": ["ESNext"], + "target": "ES6", + "esModuleInterop": true, + "moduleResolution": "NodeNext", + "module": "NodeNext", + "outDir": "dist/" + }, + "exclude": ["node_modules/", "drizzle.config.ts"] }