-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
db.ts
48 lines (40 loc) 路 1.05 KB
/
db.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Copyright (c) Crew Dev.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import { offLine } from "./logs.ts";
type pkgResponse = {
name: string;
description: string;
star_count: number;
};
/**
* get module list from deno api
* @param {string} query
*/
export async function denoApidb(query: string) {
// * get all thirt party
const response = (await fetch(
`https://api.deno.land/modules?limit=100&query=${query}`,
).catch((_) => offLine())) as Response;
const database = await response.json();
if (database?.success) {
return database?.data?.results.filter(
({ name }: pkgResponse) => name === query,
) as Array<pkgResponse>;
}
return [];
}
/**
* get module info
*/
export const moduleUrl = (name: string, version: string) =>
`https://cdn.deno.land/${name}/versions/${version}/meta/meta.json`;
/**
* get module versions
*/
export const moduleVersions = (name: string) =>
`https://cdn.deno.land/${name}/meta/versions.json`;