MCPcopy Create free account
hub / github.com/docker/getting-started / init

Function init

app/src/persistence/mysql.js:18–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16let pool;
17
18async function init() {
19 const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST;
20 const user = USER_FILE ? fs.readFileSync(USER_FILE) : USER;
21 const password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD;
22 const database = DB_FILE ? fs.readFileSync(DB_FILE) : DB;
23
24 await waitPort({
25 host,
26 port: 3306,
27 timeout: 10000,
28 waitForDns: true,
29 });
30
31 pool = mysql.createPool({
32 connectionLimit: 5,
33 host,
34 user,
35 password,
36 database,
37 charset: 'utf8mb4',
38 });
39
40 return new Promise((acc, rej) => {
41 pool.query(
42 'CREATE TABLE IF NOT EXISTS todo_items (id varchar(36), name varchar(255), completed boolean) DEFAULT CHARSET utf8mb4',
43 err => {
44 if (err) return rej(err);
45
46 console.log(`Connected to mysql db at host ${HOST}`);
47 acc();
48 },
49 );
50 });
51}
52
53async function teardown() {
54 return new Promise((acc, rej) => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…