Hansimov commited on
Commit
d6474bb
1 Parent(s): 84b077e

:recycle: [Refactor] Separate endpoints configs

Browse files
Files changed (3) hide show
  1. .gitignore +1 -1
  2. configs/endpoints.json +8 -0
  3. server.js +8 -5
.gitignore CHANGED
@@ -2,4 +2,4 @@ node_modules
2
  package-lock.json
3
  .vscode
4
  live.js
5
- secrets.json
 
2
  package-lock.json
3
  .vscode
4
  live.js
5
+ # configs/endpoints.json
configs/endpoints.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "endpoint": "https://hansimov-hf-llm-api.hf.space",
4
+ "api_key": "sk-xxxxx",
5
+ "api_type": "openai",
6
+ "need_protect": true
7
+ }
8
+ ]
server.js CHANGED
@@ -15,15 +15,18 @@ app.get("/", (req, res) => {
15
 
16
  app.get("/endpoints", async (req, res) => {
17
  try {
18
- let secrets_path = path.join(__dirname, "secrets.json");
19
- const data = await fs.readFile(secrets_path, "utf-8");
20
- const secrets = JSON.parse(data);
21
- const local_points = secrets.endpoints;
 
 
 
22
  res.json(local_points);
23
  } catch (error) {
24
  console.error(error);
25
  res.status(500).json({
26
- error: "Failed to get local endpoints: Maybe secrets.json not existed?",
27
  });
28
  }
29
  });
 
15
 
16
  app.get("/endpoints", async (req, res) => {
17
  try {
18
+ let endpoints_configs_path = path.join(
19
+ __dirname,
20
+ "configs",
21
+ "endpoints.json"
22
+ );
23
+ const data = await fs.readFile(endpoints_configs_path, "utf-8");
24
+ const local_points = JSON.parse(data);
25
  res.json(local_points);
26
  } catch (error) {
27
  console.error(error);
28
  res.status(500).json({
29
+ error: "Failed to get local endpoints: Maybe configs/endpoints.json not existed?",
30
  });
31
  }
32
  });