Compare commits
4 Commits
e1c43de439
...
abe9c6994d
Author | SHA1 | Date | |
---|---|---|---|
abe9c6994d | |||
3d08b14e0f | |||
5d6d67c51d | |||
d27bdfc4fb |
30
.github/workflows/docker.yml
vendored
30
.github/workflows/docker.yml
vendored
@ -1,30 +0,0 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build_and_push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Gitea Package Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ secrets.SERVER_URL }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.PACKAGE_TOKEN }}
|
||||
|
||||
- name: Build Docker Image
|
||||
run: docker build -t git.pontusmail.org/librecloud/mail-connect:latest .
|
||||
|
||||
- name: Push Docker Image
|
||||
run: docker push git.pontusmail.org/librecloud/mail-connect:latest
|
@ -1,7 +1,5 @@
|
||||
# mail-connect
|
||||
|
||||
[](https://github.com/ihatenodejs/mail-connect/actions/workflows/docker.yml)
|
||||
|
||||
API bridge for docker-mailserver
|
||||
|
||||
*mail-connect is still in early beta*
|
||||
@ -46,7 +44,7 @@ All features marked with an **E** are extended features, and are not a part of t
|
||||
cp .env.example .env # you don't need to change anything here
|
||||
vim ratelimit.json # optional, customize to your liking...
|
||||
```
|
||||
|
||||
|
||||
**Note:** If you are running mail-connect outside a Docker container (or changing the binds), please change the `MAILCONNECT_ROOT_DIR` to match your environment.
|
||||
|
||||
4. **Build and run the container**
|
||||
|
15
package.json
15
package.json
@ -8,32 +8,33 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/dockerode": "^3.3.37",
|
||||
"@types/dockerode": "^3.3.38",
|
||||
"@types/express": "^5.0.1",
|
||||
"@types/node": "^22.13.17",
|
||||
"@types/validator": "^13.12.3",
|
||||
"@types/node": "^22.14.1",
|
||||
"@types/validator": "^13.15.0",
|
||||
"drizzle-kit": "^0.30.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.8.2"
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/better-sqlite3": "^7.6.12",
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
"@types/figlet": "^1.7.0",
|
||||
"better-sqlite3": "^11.9.1",
|
||||
"child_process": "^1.0.2",
|
||||
"dockerode": "^4.0.5",
|
||||
"dotenv": "^16.4.7",
|
||||
"dotenv": "^16.5.0",
|
||||
"drizzle-orm": "^0.39.3",
|
||||
"express": "^4.21.2",
|
||||
"express-rate-limit": "^7.5.0",
|
||||
"figlet": "^1.8.0",
|
||||
"figlet": "^1.8.1",
|
||||
"password-validator": "^5.3.0",
|
||||
"validator": "^13.15.0"
|
||||
},
|
||||
"trustedDependencies": [
|
||||
"better-sqlite3",
|
||||
"cpu-features",
|
||||
"esbuild",
|
||||
"protobufjs",
|
||||
"ssh2"
|
||||
]
|
||||
|
52
src/actions/initialChecks.ts
Normal file
52
src/actions/initialChecks.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import fs from "fs";
|
||||
|
||||
const requiredEnvVars = ['MIGRATE_TXT', 'DB_FILE_NAME', 'MAILCONNECT_ROOT_DIR'];
|
||||
|
||||
function checkRatelimit() {
|
||||
const ratelimitExists = fs.existsSync("ratelimit.json");
|
||||
if (!ratelimitExists) {
|
||||
console.log("[!] Ratelimit config not found");
|
||||
return false;
|
||||
} else {
|
||||
console.log("[✓] Found ratelimit config");
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
function checkEnv() {
|
||||
const envExists = fs.existsSync(".env");
|
||||
if (!envExists) {
|
||||
console.log("[!] .env file not found");
|
||||
return false;
|
||||
} else {
|
||||
console.log("[✓] Found .env file");
|
||||
let allVarsPresent = true;
|
||||
|
||||
for (const envVar of requiredEnvVars) {
|
||||
if (!process.env[envVar]) {
|
||||
console.log(` [!] ${envVar} not found`);
|
||||
allVarsPresent = false;
|
||||
} else {
|
||||
console.log(` [✓] Found ${envVar}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!allVarsPresent) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// the return value of this function determines if server should exit early
|
||||
export default function initialChecks() {
|
||||
const ratelimitCheck = checkRatelimit();
|
||||
const envCheck = checkEnv();
|
||||
|
||||
if (!ratelimitCheck || !envCheck) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
@ -5,10 +5,20 @@ import { listAccounts } from "./actions/accounts/listAccounts";
|
||||
import { getUserAccount } from "./actions/accounts/getUserAccount";
|
||||
import { updatePassword } from "./actions/accounts/updatePassword";
|
||||
import { addAccount } from "./actions/accounts/addAccount";
|
||||
import initialChecks from "./actions/initialChecks";
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
|
||||
console.log("==== SELF CHECK STARTING ====\n");
|
||||
const rCResult = initialChecks();
|
||||
if (!rCResult) {
|
||||
console.log("\n==== SELF CHECK FAIL ====");
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log("\n==== SELF CHECK PASS ====\n");
|
||||
}
|
||||
|
||||
interface RateLimitOptions {
|
||||
windowMs: number;
|
||||
limit: number;
|
||||
@ -35,7 +45,7 @@ app.listen(PORT, () => {
|
||||
console.log('mail-connect');
|
||||
console.log('Version: 0.1.1');
|
||||
console.log(`API listening on port ${PORT}\n`);
|
||||
console.dir("[!] " + err);
|
||||
console.log("[!] " + err);
|
||||
} else {
|
||||
console.log(data);
|
||||
console.log('Version: 0.1.1');
|
||||
|
Loading…
x
Reference in New Issue
Block a user