Skip to content

Commit

Permalink
fix: consolidate error handling into catch (resolves #24) (#25)
Browse files Browse the repository at this point in the history
fix: set GIT_HOSTNAME for GitLab (resolves #23)
chore(docs): add note about GIT_HOSTNAME
fix: add NVM configuration
  • Loading branch information
greatislander authored Jun 27, 2024
1 parent ac7c0c8 commit a01043c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.x
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ OAUTH_CLIENT_ID=""
OAUTH_CLIENT_SECRET=""
```

If you are using GitHub Enterprise Server or a self-hosted instance of GitLab you'll also need to set `GIT_HOSTNAME` to the hostname of your server.

### Serving locally

1. Install the required packages: `npm install`
Expand Down
8 changes: 2 additions & 6 deletions middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const authMiddleware = () => {
ALLOWED_DOMAINS,
OAUTH_CLIENT_ID,
OAUTH_CLIENT_SECRET,
GIT_HOSTNAME = "github.com",
GIT_HOSTNAME = provider === "github" ? "github.com" : "gitlab.com",
} = process.env;

// Check if the domain is whitelisted
Expand Down Expand Up @@ -191,7 +191,7 @@ const callbackMiddleware = () => {
const {
OAUTH_CLIENT_ID,
OAUTH_CLIENT_SECRET,
GIT_HOSTNAME = "github.com",
GIT_HOSTNAME = provider === "github" ? "github.com" : "gitlab.com",
} = process.env;

if (!OAUTH_CLIENT_ID || !OAUTH_CLIENT_SECRET) {
Expand Down Expand Up @@ -245,10 +245,6 @@ const callbackMiddleware = () => {
body: JSON.stringify(requestBody),
});
} catch {
//
}

if (!response) {
res.set(defaultHeaders);
res.send(
htmlResponse({
Expand Down
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@
"prepare": "husky",
"test": "c8 --all -r clover -r text ava"
},
"keywords": [
"decap-cms",
"sveltia-cms",
"github",
"gitlab",
"auth"
],
"keywords": ["decap-cms", "sveltia-cms", "github", "gitlab", "auth"],
"author": "OCAD University <[email protected]>",
"license": "BSD-3-Clause",
"dependencies": {
Expand All @@ -37,8 +31,6 @@
"supertest": "^7.0.0"
},
"lint-staged": {
"*.{js,json}": [
"biome check --write --no-errors-on-unmatched"
]
"*.{js,json}": ["biome check --write --no-errors-on-unmatched"]
}
}

0 comments on commit a01043c

Please sign in to comment.