|
@@ -0,0 +1,20 @@
|
|
|
+const DB_PATH = process.env.DB_PATH;
|
|
|
+const db = require('better-sqlite3')(DB_PATH);
|
|
|
+
|
|
|
+export async function get(req, res, next) {
|
|
|
+ const { id } = req.params;
|
|
|
+ if (!id) next()
|
|
|
+ const item = db
|
|
|
+ .prepare(`SELECT source, target
|
|
|
+ FROM translations
|
|
|
+ WHERE lemma_id = ?
|
|
|
+ `)
|
|
|
+ .all(id)
|
|
|
+ if (item) {
|
|
|
+ res.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
+ res.setHeader('Content-Type', 'application/json');
|
|
|
+ res.end(JSON.stringify(item));
|
|
|
+ } else {
|
|
|
+ next();
|
|
|
+ }
|
|
|
+}
|