rhythia-api 80.0.0 → 81.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/handleApi.ts +10 -8
  2. package/package.json +1 -1
package/handleApi.ts CHANGED
@@ -1,16 +1,18 @@
1
1
  import { z } from "zod";
2
-
2
+ let env = "development";
3
+ export function setEnvironment(
4
+ stage: "development" | "testing" | "production"
5
+ ) {
6
+ env = stage;
7
+ }
3
8
  export function handleApi<
4
9
  T extends { url: string; input: z.ZodObject<any>; output: z.ZodObject<any> }
5
10
  >(apiSchema: T) {
6
11
  return async (input: T["input"]["_type"]): Promise<T["output"]["_type"]> => {
7
- const response = await fetch(
8
- `https://${process.env.API_STAGE}.rhythia.com${apiSchema.url}`,
9
- {
10
- method: "POST",
11
- body: JSON.stringify(input),
12
- }
13
- );
12
+ const response = await fetch(`https://${env}.rhythia.com${apiSchema.url}`, {
13
+ method: "POST",
14
+ body: JSON.stringify(input),
15
+ });
14
16
  const output = await response.json();
15
17
  return output;
16
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "80.0.0",
3
+ "version": "81.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",