-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add validate config commmand * move files to server utils * move utils package to server * update error handler middleware * add config path to start command * remove process exit * move comand * move action functions to files * update logger for start action * update changeset
- Loading branch information
1 parent
84049b0
commit 4bee000
Showing
37 changed files
with
159 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@gateweaver/policies": patch | ||
"@gateweaver/server": patch | ||
"@gateweaver/cli": patch | ||
--- | ||
|
||
Update CLI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ endpoints: | |
test-header: "test" | ||
policies: | ||
- cors | ||
- rateLimit | ||
- path: "/todos" | ||
method: "POST" | ||
target: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/src/generate-api-key.ts → packages/cli/src/actions/generate-api-key.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { startAction } from "./start"; | ||
export { validateAction } from "./validate"; | ||
export { generateApiKeyAction } from "./generate-api-key"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { logger, startServer } from "@gateweaver/server/utils"; | ||
|
||
export const startAction = (configPath: string) => { | ||
try { | ||
startServer(configPath); | ||
} catch (error) { | ||
logger.error(error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { parseConfig, InvalidConfigError } from "@gateweaver/server/utils"; | ||
|
||
export const validateAction = (configPath: string) => { | ||
try { | ||
parseConfig(configPath); | ||
console.log("✅ Config file is valid"); | ||
} catch (error) { | ||
if (error instanceof InvalidConfigError) { | ||
const validationErrors = error.message.split("\n"); | ||
|
||
console.error("❌ Config file validation errors:"); | ||
validationErrors.map((error) => console.error(`- ${error}`)); | ||
} else { | ||
console.error((error as Error).message); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { RateLimitUnauthorizedError } from "./key-generator"; | ||
export * from "./rate-limit.schema"; | ||
export * from "./rate-limit.middleware"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import { config } from "dotenv"; | ||
config({ path: ".env.gateweaver" }); | ||
import { logger } from "@gateweaver/utils"; | ||
import { startServer } from "./start-server"; | ||
import { startServer, logger, InvalidConfigError } from "./utils"; | ||
|
||
try { | ||
startServer(); | ||
} catch (error) { | ||
logger.error(error); | ||
process.exit(1); | ||
if (error instanceof InvalidConfigError) { | ||
const validationErrors = error.message.split("\n"); | ||
|
||
logger.error("Invalid config file"); | ||
logger.error(validationErrors); | ||
} else { | ||
logger.error(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { errorHandler } from "./error-handler.middleware"; |
Oops, something went wrong.