-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
72 lines (58 loc) · 1.78 KB
/
setup.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Setup the project once.
*/
const init_time = Date.now()
import fs from 'fs';
import path from 'path';
import dotenv from 'dotenv';
dotenv.config();
import pgPromise from 'pg-promise';
const db = pgPromise()({
host: process.env.POSTGRES_HOST,
port: process.env.POSTGRES_PORT,
database: process.env.POSTGRES_DB,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
});
import { customAlphabet } from 'nanoid';
export function generateId(prefix, length=16) {
const nanoid = customAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
return [prefix, nanoid(16)].join("_");
}
let pipeFolderId = generateId("folder");
await db.none(
`INSERT INTO folders (id, name, type, cloud, root)
VALUES ($[id], $[name], $[type], $[cloud], $[root])`, {
id: pipeFolderId,
name: "pipe",
type: "repo",
cloud: false,
root: "C:/Users/calvi/3D Objects/pipe"
});
await db.none(
`INSERT INTO files (id, type, extension, basename, folder_id, visibility)
VALUES ($[id], $[type], $[extension], $[basename], $[folder_id], $[visibility])`, {
id: "pipe",
type: "script",
extension: "py",
basename: "main",
folder_id: pipeFolderId,
visibility: "private",
});
// await db.none(
// "INSERT INTO variables (id, value) VALUES ($1, $2)", [
// "ELEVENLABS-UPNORTH-JEREYMI-2",
// "localenv",
// ])
// await db.none(
// "INSERT INTO jobs (id, tldr, status, parent_id) VALUES ($1, $2, $3, $4)", [
// generateId("job"),
// "create an upnorth video about fitness",
// "pending",
// null,
// ])
// console.log(
// (await db.any("SELECT * FROM jobs")).rows
// )
console.log(`\n>> setup took ${Date.now() - init_time}\n`)
process.exit(0)