-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathconfig-remote-migration-files-github-api.ts
More file actions
35 lines (28 loc) · 985 Bytes
/
config-remote-migration-files-github-api.ts
File metadata and controls
35 lines (28 loc) · 985 Bytes
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
import {
ClientSQLite,
isMigrationFile,
NessieConfig,
} from "https://deno.land/x/nessie/mod.ts";
/**
* This example uses the github api to get the the folder content of a repository.
* See https://docs.github.com/en/rest/reference/repos#get-repository-content for documentation.
*/
type ResponseFormat = {
download_url: string;
name: string;
};
const res = await fetch(
"https://api.github.com/repos/halvardssm/deno-nessie/contents/examples",
{ headers: { "Authorization": `token some-token` } },
);
// Here we arrume that the url is to a directory and that we get an array back
const body = await res.json() as ResponseFormat[];
//We only want migration files
const migrationFiles = body.filter((el) => isMigrationFile(el.name))
// We are only interested in the raw url of the file
.map((el) => el.download_url);
const config: NessieConfig = {
client: new ClientSQLite("sqlite.db"),
additionalMigrationFiles: migrationFiles,
};
export default config;