Skip to content

Commit 454a518

Browse files
committed
docs: mixed use of tabs and spaces causing indent issues
1 parent ea8b295 commit 454a518

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

src/content/docs/connect-drizzle-proxy.mdx

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,27 @@ const port = 3000;
8484
const client = new Client('postgres://postgres:postgres@localhost:5432/postgres');
8585

8686
app.post('/query', async (req, res) => {
87-
const { sql, params, method } = req.body;
87+
const { sql, params, method } = req.body;
8888

89-
// prevent multiple queries
90-
const sqlBody = sql.replace(/;/g, '');
89+
// prevent multiple queries
90+
const sqlBody = sql.replace(/;/g, '');
9191

92-
try {
93-
const result = await client.query({
94-
text: sqlBody,
95-
values: params,
96-
rowMode: method === 'all' ? 'array': undefined,
97-
});
98-
res.send(result.rows);
99-
} catch (e: any) {
100-
res.status(500).json({ error: e });
101-
}
102-
103-
res.status(500).json({ error: 'Unknown method value' });
92+
try {
93+
const result = await client.query({
94+
text: sqlBody,
95+
values: params,
96+
rowMode: method === 'all' ? 'array': undefined,
97+
});
98+
res.send(result.rows);
99+
} catch (e: any) {
100+
res.status(500).json({ error: e });
101+
}
102+
103+
res.status(500).json({ error: 'Unknown method value' });
104104
});
105105

106106
app.listen(port, () => {
107-
console.log(`Example app listening on port ${port}`);
107+
console.log(`Example app listening on port ${port}`);
108108
});
109109
```
110110
</Section>
@@ -138,10 +138,10 @@ const main = async () => {
138138
const connection = await mysql.createConnection('mysql://root:[email protected]:5432/drizzle');
139139

140140
app.post('/query', async (req, res) => {
141-
const { sql, params, method } = req.body;
141+
const { sql, params, method } = req.body;
142142

143143
// prevent multiple queries
144-
const sqlBody = sql.replace(/;/g, '');
144+
const sqlBody = sql.replace(/;/g, '');
145145

146146
try {
147147
const result = await connection.query({
@@ -155,20 +155,20 @@ const main = async () => {
155155
return next();
156156
},
157157
});
158-
} catch (e: any) {
159-
res.status(500).json({ error: e });
160-
}
161-
162-
if (method === 'all') {
163-
res.send(result[0]);
164-
} else if (method === 'execute') {
165-
res.send(result);
166-
}
167-
res.status(500).json({ error: 'Unknown method value' });
158+
} catch (e: any) {
159+
res.status(500).json({ error: e });
160+
}
161+
162+
if (method === 'all') {
163+
res.send(result[0]);
164+
} else if (method === 'execute') {
165+
res.send(result);
166+
}
167+
res.status(500).json({ error: 'Unknown method value' });
168168
});
169169

170170
app.listen(port, () => {
171-
console.log(`Example app listening on port ${port}`);
171+
console.log(`Example app listening on port ${port}`);
172172
});
173173
}
174174

@@ -205,15 +205,15 @@ type ResponseType = { rows: any[][] | any[] }[];
205205
const db = drizzle(async (sql, params, method) => {
206206
// single queries logic. Same as in code above
207207
}, async (queries: { sql: string, params: any[], method: 'all' | 'run' | 'get' | 'values'}[]) => {
208-
try {
209-
const result: ResponseType = await axios.post('http://localhost:3000/batch', { queries });
210-
211-
return result;
212-
} catch (e: any) {
213-
console.error('Error from sqlite proxy server:', e);
214-
throw e;
215-
}
216-
});
208+
try {
209+
const result: ResponseType = await axios.post('http://localhost:3000/batch', { queries });
210+
211+
return result;
212+
} catch (e: any) {
213+
console.error('Error from sqlite proxy server:', e);
214+
throw e;
215+
}
216+
});
217217
```
218218

219219
And then you can use `db.batch([])` method, that will proxy all queries

0 commit comments

Comments
 (0)